本文整理汇总了PHP中CollectionType类的典型用法代码示例。如果您正苦于以下问题:PHP CollectionType类的具体用法?PHP CollectionType怎么用?PHP CollectionType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CollectionType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: view
/**
* Views the composer edit page.
* @param string|int $ctID The collection type
* @param string|int $cPublishParentID The parent page under which to publish
*/
public function view($ctID = false, $cPublishParentID = false)
{
// Load Page objects from their IDs
$ct = $this->setCollectionType($ctID);
$cPublishParent = Page::getByID($cPublishParent);
// If we couldn't load a collection type, send them to the composer menu
if (!is_object($ct)) {
$ctArray = CollectionType::getComposerPageTypes();
// If there's only one collection type, just choose that one
if (count($ctArray) === 1) {
$ct = $ctArray[0];
$this->redirect('/dashboard/composer/write', $ct->getCollectionTypeID());
exit;
}
// Otherwise, they need to choose the CT from this array of types
$this->set('ctArray', $ctArray);
} else {
// CT was set, so create a draft of this type
$entry = ComposerPage::createDraft($ct);
if (is_object($entry)) {
// Check if we have a parent specified to create this draft under
if ($cPublishParentID && is_object($cPublishParent)) {
// Make this draft under the specified parent
$entry->setComposerDraftPublishParentID($cPublishParentID);
}
// New draft is created, so start editing it
$this->redirect('/dashboard/composer/write', 'edit', $entry->getCollectionID());
} else {
// Something failed when trying to create a draft, so send back to drafts folder
$this->redirect('/dashboard/composer/drafts');
}
}
}
开发者ID:r-bansal,项目名称:janeswalk-web-1,代码行数:38,代码来源:write.php
示例2: activate_files
public function activate_files($ptID)
{
try {
Loader::model("collection_types");
$pt = PageTheme::getByID($ptID);
$txt = Loader::helper('text');
if (!is_array($this->post('pageTypes'))) {
throw new Exception(t("You must specify at least one template to make into a page type."));
}
$pkg = false;
$pkgHandle = $pt->getPackageHandle();
if ($pkgHandle) {
$pkg = Package::getByHandle($pkgHandle);
}
foreach ($this->post('pageTypes') as $ptHandle) {
$data['ctName'] = $txt->unhandle($ptHandle);
$data['ctHandle'] = $ptHandle;
$ct = CollectionType::add($data, $pkg);
}
$this->set('message', t('Files in the theme were activated successfully.'));
} catch (Exception $e) {
$this->set('error', $e);
}
$this->view($ptID);
}
开发者ID:Zyqsempai,项目名称:amanet,代码行数:25,代码来源:inspect.php
示例3: do_add
public function do_add()
{
$ctName = $_POST['ctName'];
$ctHandle = $_POST['ctHandle'];
$error = array();
if (!$ctHandle) {
$this->error->add(t("Handle required."));
}
if (!$ctName) {
$this->error->add(t("Name required."));
}
$valt = Loader::helper('validation/token');
if (!$valt->validate('add_page_type')) {
$this->error->add($valt->getErrorMessage());
}
$akIDArray = $_POST['akID'];
if (!is_array($akIDArray)) {
$akIDArray = array();
}
if (!$this->error->has()) {
try {
if ($_POST['task'] == 'add') {
$nCT = CollectionType::add($_POST);
$this->redirect('/dashboard/pages/types', 'page_type_added');
}
exit;
} catch (Exception $e1) {
$this->error->add($e1->getMessage());
}
}
}
开发者ID:nbourguig,项目名称:concrete5,代码行数:31,代码来源:add.php
示例4: addStack
public static function addStack($stackName, $type = self::ST_TYPE_USER_ADDED) {
$ct = new CollectionType();
$data = array();
$parent = Page::getByPath(STACKS_PAGE_PATH);
$data = array();
$data['name'] = $stackName;
if (!$stackName) {
$data['name'] = t('No Name');
}
$pagetype = CollectionType::getByHandle(STACKS_PAGE_TYPE);
$page = $parent->add($pagetype, $data);
// we have to do this because we need the area to exist before we try and add something to it.
$a = Area::getOrCreate($page, STACKS_AREA_NAME);
// finally we add the row to the stacks table
$db = Loader::db();
$stackCID = $page->getCollectionID();
$v = array($stackName, $stackCID, $type);
$db->Execute('insert into Stacks (stName, cID, stType) values (?, ?, ?)', $v);
//Return the new stack
return self::getByID($stackCID);
}
开发者ID:nveid,项目名称:concrete5,代码行数:25,代码来源:model.php
示例5: save
public function save()
{
$this->verify($this->post('ctID'));
if ($this->post('ctIncludeInComposer')) {
switch ($this->post('ctComposerPublishPageMethod')) {
case 'PARENT':
$page = Page::getByID($this->post('ctComposerPublishPageParentID'));
if ($page->isError()) {
$this->error->add(t('Parent page not selected'));
} else {
$this->ct->saveComposerPublishTargetPage($page);
}
break;
case 'PAGE_TYPE':
$ct = CollectionType::getByID($this->post('ctComposerPublishPageTypeID'));
$this->ct->saveComposerPublishTargetPageType($ct);
break;
default:
$this->ct->saveComposerPublishTargetAll();
break;
}
if (!$this->error->has()) {
$this->ct->saveComposerAttributeKeys($this->post('composerAKID'));
$this->redirect('/dashboard/pages/types/composer', 'view', $this->ct->getCollectionTypeID(), 'updated');
} else {
$this->view($this->ct->getCollectionTypeID());
}
} else {
$this->ct->resetComposerData();
$this->redirect("/dashboard/pages/types", "clear_composer");
}
}
开发者ID:ojalehto,项目名称:concrete5-legacy,代码行数:32,代码来源:composer.php
示例6: createPage
public function createPage()
{
Loader::model('page');
$parent = Page::getByID($this->location);
$ct = CollectionType::getByID($this->ctID);
$data = array('cName' => $this->post->title, 'cHandle' => $this->post->page_title, 'cDescription' => $this->post->description, 'cDatePublic' => $this->post->pubDate);
$p = $parent->add($ct, $data);
return $p;
}
开发者ID:pranastae,项目名称:problog_importer,代码行数:9,代码来源:c5_xml.php
示例7: isValidComposerPage
/**
* Checks to see if the page in question is a valid composer draft for the logged in user
*/
protected static function isValidComposerPage($entry) {
$ct = CollectionType::getByID($entry->getCollectionTypeID());
if (!$ct->isCollectionTypeIncludedInComposer()) {
return false;
}
$cp = new Permissions($entry);
if (!$cp->canEditPageContents()) {
return false;
}
return true;
}
开发者ID:nveid,项目名称:concrete5,代码行数:14,代码来源:composer_page.php
示例8: testPageOperations
public function testPageOperations()
{
Loader::model('page');
Loader::model('collection_types');
$ct = CollectionType::getByHandle('left_sidebar');
//everything's got a default..
$this->assertInstanceOf('CollectionType', $ct);
//kind of weird to check this but hey
$home = Page::getByID(HOME_CID);
$pageName = "My Cool Page";
$pageHandle = 'page';
//this tests that page handles will be set as the page handle.
//The actual add function does some transforms on the handles if they are not
//set.
$badPage = Page::getByID(42069);
try {
$page = $badPage->add($ct, array('uID' => 1, 'cName' => $pageName, 'cHandle' => $pageHandle));
} catch (Exception $e) {
$caught = true;
}
if (!$caught) {
$this->fail('Added a page to a non-page');
}
$page = self::createPage($pageName, $pageHandle);
$parentID = $page->getCollectionParentID();
$this->assertInstanceOf('Page', $page);
$this->assertEquals($parentID, HOME_CID);
$this->assertSame($pageName, $page->getCollectionName());
$this->assertSame($pageHandle, $page->getCollectionHandle());
$this->assertSame('/' . $pageHandle, $page->getCollectionPath());
//now we know adding pages works.
$destination = self::createPage("Destination");
$parentCID = $destination->getCollectionID();
$page->move($destination);
$parentPath = $destination->getCollectionPath();
$handle = $page->getCollectionHandle();
$path = $page->getCollectionPath();
$this->assertSame($parentPath . '/' . $handle, $path);
$this->assertSame($parentCID, $page->getCollectionParentID());
//now we know that moving pages works
$page->moveToTrash();
$this->assertTrue($page->isInTrash());
//stuff is going to the trash
$cID = $page->getCollectionID();
$page->delete();
$noPage = Page::getByID($cID);
$this->assertEquals(COLLECTION_NOT_FOUND, $noPage->error);
//maybe there is a more certain way to determine this.
//now we know deleting pages works
$destination->delete();
//clean up the destination page
}
开发者ID:ojalehto,项目名称:concrete5-legacy,代码行数:52,代码来源:PageTest.php
示例9: run
public function run()
{
BlockType::installBlockType('tags');
BlockType::installBlockType('next_previous');
BlockType::installBlockType('date_nav');
Loader::model('collection_types');
$blogEntry = CollectionType::getByHandle('blog_entry');
if (!$blogEntry || !intval($blogEntry->getCollectionTypeID())) {
$data['ctHandle'] = 'blog_entry';
$data['ctName'] = t('Blog Entry');
$blogEntry = CollectionType::add($data);
}
}
开发者ID:Zyqsempai,项目名称:amanet,代码行数:13,代码来源:version_541.php
示例10: install
public function install()
{
Loader::model('collection_types');
$pkg = parent::install();
PageTheme::add('casual', $pkg);
$pagetypearray = array(array("left_sidebar", "Left Sidebar"), array("right_sidebar", "Right Sidebar"), array("full", "One Column"), array("three_column", "Three Column Layout"));
foreach ($pagetypearray as $value) {
$pageType = CollectionType::getByHandle($value[0]);
if (!$pageType) {
$pkg = Package::getByHandle('casual');
$newPageType = CollectionType::add(array('ctHandle' => $value[0], 'ctName' => t($value[1])), $pkg);
} else {
$newPageType = $pageType;
}
}
}
开发者ID:Zyqsempai,项目名称:amanet,代码行数:16,代码来源:controller.php
示例11: delete
public function delete($ctID, $token = '') {
$db = Loader::db();
$valt = Loader::helper('validation/token');
if (!$valt->validate('delete_page_type', $token)) {
$this->set('message', $valt->getErrorMessage());
} else {
// check to make sure we
$pageCount = $db->getOne("SELECT COUNT(*) FROM Pages WHERE cIsTemplate = 0 and ctID = ?",array($ctID));
if($pageCount == 0) {
$ct = CollectionType::getByID($ctID);
$ct->delete();
$this->redirect("/dashboard/pages/types");
} else {
$this->set("error", array(t("You must delete all pages of this type before deleting this page type.")));
}
}
}
开发者ID:rii-J,项目名称:concrete5-de,代码行数:18,代码来源:controller.php
示例12: getUnstartedWalk
/**
* Find the latest unstarted walk, so you don't need to make a new one.
* @param $u The user for whom you're finding their walk
* @return Collection
*/
protected function getUnstartedWalk(User $u, Page $city)
{
// Find all walks for this user, in this city, with no name
$pl = new PageList();
$pl->filterByCollectionTypeHandle('walk');
$pl->filterByUserID($u->getUserID());
$pl->filterByParentID($city->getCollectionID());
$pl->displayUnapprovedPages();
$pl->filterByName('', true);
$pl->filterByAttribute('exclude_page_list', true);
// Arbitrarily use the first; it's blank anyway.
$walk = $pl->get(1)[0];
// If you couldn't find a walk, make a new one in the city
if (!$walk) {
$walk = $city->add(CollectionType::getByHandle('walk'), []);
$walk->setAttribute('exclude_page_list', true);
}
return $walk;
}
开发者ID:r-bansal,项目名称:janeswalk-web-1,代码行数:24,代码来源:form.php
示例13: do_add
public function do_add()
{
$ctName = $_POST['ctName'];
$ctHandle = $_POST['ctHandle'];
$vs = Loader::helper('validation/strings');
$error = array();
if (!$ctHandle) {
$this->error->add(t("Handle required."));
} else {
if (!$vs->handle($ctHandle)) {
$this->error->add(t('Handles must contain only letters, numbers or the underscore symbol.'));
}
}
if (CollectionType::getByHandle($ctHandle)) {
$this->error->add(t('Handle already exists.'));
}
if (!$ctName) {
$this->error->add(t("Name required."));
} else {
if (preg_match('/[<>{};?"`]/i', $ctName)) {
$this->error->add(t('Invalid characters in page type name.'));
}
}
$valt = Loader::helper('validation/token');
if (!$valt->validate('add_page_type')) {
$this->error->add($valt->getErrorMessage());
}
$akIDArray = $_POST['akID'];
if (!is_array($akIDArray)) {
$akIDArray = array();
}
if (!$this->error->has()) {
try {
if ($_POST['task'] == 'add') {
$nCT = CollectionType::add($_POST);
$this->redirect('/dashboard/pages/types', 'page_type_added');
}
exit;
} catch (Exception $e1) {
$this->error->add($e1->getMessage());
}
}
}
开发者ID:ojalehto,项目名称:concrete5-legacy,代码行数:43,代码来源:add.php
示例14: show
/**
* Gets a list of all pages of the collection type
* specified by $ctID
*
* @param int $ctID ID of collection type
*/
public function show($ctID)
{
$hh = Loader::helper('html');
$th = Loader::helper('text');
$emptyList = false;
$this->view(false);
Loader::model('page_list');
$pl = new PageList();
$pl->filterByCollectionTypeID($ctID);
if (array_key_exists('cvName', $_REQUEST)) {
$cvName = $th->sanitize($_REQUEST['cvName']);
$this->set('cvName', $cvName);
$pl->filterByName($cvName);
if (count($pl->getPage()) <= 0) {
$pl = new PageList();
$emptyList = true;
}
}
if (!$emptyList) {
$pl->addtoQuery('left join Pages parent ON(p1.cParentID = parent.cID)');
$pl->sortByMultiple('parent.cDisplayOrder asc', 'p1.cDisplayOrder asc');
$pages = $pl->getPage();
} else {
$pages = '';
$this->set('emptyList', t('No entries found'));
}
$ct = CollectionType::getByID($ctID);
// add all necessary header items like JavaScript and CSS files
if (!array_key_exists('cvName', $_REQUEST) || $cvName == '') {
$this->addHeaderItem($hh->css('composer.sort.css', 'remo_composer_list'));
$this->addHeaderItem($hh->javascript('composer.sort.js', 'remo_composer_list'));
}
$this->addHeaderItem($hh->javascript('composer.overview.js', 'remo_composer_list'));
// add variables used by view
$this->set('customColumns', $this->loadCustomColumns($ctID));
$this->set('ctID', $ctID);
$this->set('ctPublishMethod', $ct->getCollectionTypeComposerPublishMethod());
$this->set('pages', $pages);
$this->set('displaySearchBox', $this->displaySearchBox());
$this->set('composerListTitel', $ct->getCollectionTypeName());
$this->set('pagesPagination', $pl->displayPaging(false, true));
}
开发者ID:haeflimi,项目名称:concrete5-composer-list,代码行数:48,代码来源:list.php
示例15: add_personal_homepage
private function add_personal_homepage($user_name, $nick_name, $doc_lang)
{
$page = Page::getByPath("/{$doc_lang}/engineer/{$user_name}");
if ($page->getCollectionID() > 0) {
$this->set('error', t('Existed username: %s!', $user_name));
return false;
}
$page_type = CollectionType::getByHandle('personal_homepage');
$parent_page = Page::getByPath("/{$doc_lang}/engineer");
$page = $parent_page->add($page_type, array('cName' => $nick_name, 'cHandle' => $user_name));
if ($page instanceof Page) {
$block_type = BlockType::getByHandle("fse_public_profile");
$area = new Area('Side Bar');
$page->addBlock($block_type, $area, array("fseUsername" => $user_name));
} else {
$this->set('error', t('Failed to create personal homepage!'));
return false;
}
return true;
}
开发者ID:rratcliffe,项目名称:fsen,代码行数:20,代码来源:fse_register.php
示例16: update
public function update()
{
$valt = Loader::helper('validation/token');
$ct = CollectionType::getByID($_REQUEST['ctID']);
$ctName = $_POST['ctName'];
$ctHandle = $_POST['ctHandle'];
$vs = Loader::helper('validation/strings');
if (!$ctHandle) {
$this->error->add(t("Handle required."));
} else {
if (!$vs->handle($ctHandle)) {
$this->error->add(t('Handles must contain only letters, numbers or the underscore symbol.'));
}
}
if (!$ctName) {
$this->error->add(t("Name required."));
} else {
if (preg_match('/[<>;{}?"`]/i', $ctName)) {
$this->error->add(t('Invalid characters in page type name.'));
}
}
if (!$valt->validate('update_page_type')) {
$this->error->add($valt->getErrorMessage());
}
if (!$this->error->has()) {
try {
if (is_object($ct)) {
$ct->update($_POST);
$this->redirect('/dashboard/pages/types', 'page_type_updated');
}
} catch (Exception $e1) {
$this->error->add($e1->getMessage());
}
}
$this->view();
}
开发者ID:ronlobo,项目名称:concrete5,代码行数:36,代码来源:types.php
示例17: swapContent
public function swapContent($options)
{
if ($this->validateClearSiteContents($options)) {
Loader::model("page_list");
Loader::model("file_list");
Loader::model("stack/list");
$pl = new PageList();
$pages = $pl->get();
foreach ($pages as $c) {
$c->delete();
}
$fl = new FileList();
$files = $fl->get();
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 = CollectionType::getList();
foreach ($pageTypes as $ct) {
$ct->delete();
}
// now we add in any files that this package has
if (is_dir($this->getPackagePath() . '/content_files')) {
Loader::library('file/importer');
$fh = new FileImporter();
$contents = Loader::helper('file')->getDirectoryContents($this->getPackagePath() . '/content_files');
foreach ($contents as $filename) {
$f = $fh->import($this->getPackagePath() . '/content_files/' . $filename, $filename);
}
}
// now we parse the content.xml if it exists.
Loader::library('content/importer');
$ci = new ContentImporter();
$ci->importContentFile($this->getPackagePath() . '/content.xml');
}
}
开发者ID:ojalehto,项目名称:concrete5-legacy,代码行数:45,代码来源:package.php
示例18: array
?>
<div class="controls">
<?php
echo $form->text('cvName', $searchRequest['cvName'], array('style' => 'width: 120px'));
?>
</div>
</div>
<div class="span3">
<?php
echo $form->label('ctID', t('Page Type'));
?>
<div class="controls">
<?
Loader::model('collection_types');
$ctl = CollectionType::getList();
$ctypes = array('' => t('** All'));
foreach($ctl as $ct) {
$ctypes[$ct->getCollectionTypeID()] = $ct->getCollectionTypeName();
}
print $form->select('ctID', $ctypes, $searchRequest['ctID'], array('style' => 'width:120px'))?>
</div>
</div>
<div class="span3">
<?php
echo $form->label('numResults', t('# Per Page'));
?>
<div class="controls">
开发者ID:nveid,项目名称:concrete5,代码行数:31,代码来源:search_form_advanced.php
示例19: defined
<?php defined('C5_EXECUTE') or die("Access Denied."); ?>
<?php $c = Page::getCurrentPage(); ?>
<ul id="ccm-pagelist-tabs" class="ccm-dialog-tabs">
<li class="ccm-nav-active"><a id="ccm-pagelist-tab-add" href="javascript:void(0);"><?php echo ($bID>0)? t('Edit') : t('Add') ?></a></li>
<li class=""><a id="ccm-pagelist-tab-preview" href="javascript:void(0);"><?php echo t('Preview')?></a></li>
</ul>
<input type="hidden" name="pageListToolsDir" value="<?php echo $uh->getBlockTypeToolsURL($bt)?>/" />
<div id="ccm-pagelistPane-add" class="ccm-pagelistPane">
<div class="ccm-block-field-group">
<h2><?php echo t('Number and Type of Pages')?></h2>
<?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">** <?php echo t('All')?> **</option>
<?php foreach ($ctArray as $ct) { ?>
<option value="<?php echo $ct->getCollectionTypeID()?>" <?php if ($ctID == $ct->getCollectionTypeID()) { ?> selected <?php } ?>>
<?php echo $ct->getCollectionTypeName()?>
</option>
<?php } ?>
</select>
<?php } ?>
<h2><?php echo t('Filter')?></h2>
<?php
开发者ID:rii-J,项目名称:concrete5-de,代码行数:31,代码来源:page_list_form.php
示例20: defined
<?php
defined('C5_EXECUTE') or die("Access Denied.");
global $c;
// grab all the collections belong to the collection type that we're looking at
Loader::model('collection_types');
$ctID = $c->getCollectionTypeID();
$ct = CollectionType::getByID($ctID);
$cList = $ct->getPages();
?>
<div class="ccm-ui">
<form method="post" id="ccmBlockMasterCollectionForm" action="<?php
echo $b->getBlockMasterCollectionAliasAction();
?>
">
<?php
if (count($cList) == 0) {
?>
<?php
echo t("There are no pages of this type added to your website. If there were, you'd be able to choose which of those pages this block appears on.");
?>
<?php
} else {
?>
<p><?php
echo t("Choose which pages below this particular block should appear on. Any previously selected blocks may also be removed using the checkbox. Click the checkbox in the header to select/deselect all pages.");
?>
开发者ID:ricardomccerqueira,项目名称:rcerqueira.portfolio,代码行数:31,代码来源:block_master_collection_alias.php
注:本文中的CollectionType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论