当前位置: 首页>>代码示例>>PHP>>正文


PHP CollectionType::add方法代码示例

本文整理汇总了PHP中CollectionType::add方法的典型用法代码示例。如果您正苦于以下问题:PHP CollectionType::add方法的具体用法?PHP CollectionType::add怎么用?PHP CollectionType::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CollectionType的用法示例。


在下文中一共展示了CollectionType::add方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: installPageTypes

 private function installPageTypes($pkg)
 {
     //
     //		Often page types are needed by packages.
     //
     $boilerplate = CollectionType::getByHandle('boilerplate');
     if (!is_object($boilerplate)) {
         /*
          * Other arguments you can pass in:
          * 
          * ctIsInternal boolean - will prevent page type from showing up
          * in the add page dialog and page_types dashboard page
          * 
          * ctIcon - filename for the icon in the add page dialog, not sure
          * if this has to exist somewhere, or if it can be a full http://
          * path. the system just has filenames
          * 
          * cDescription - self explanatory
          * 
          * akID = array - each element would be the id of an attribute that
          * you would like to be associated with the page on the add screen
          * 
          * this is how to get the id of the attribute you want
          * $ak = CollectionAttributeKey::getByHandle('your_handle');
          * $akID = $ak->getAttributeKeyID();
          * 
          */
         $data = array('ctHandle' => 'boilerplate', 'ctName' => t('Boilerplate Page'));
         $boilerplate = CollectionType::add($data, $pkg);
     }
     /*
      * Now that we have the boilerplate page type, we want to grab the master
      * collection and add a block to it
      */
     $bpMC = $boilerplate->getMasterTemplate();
     $bt = BlockType::getByHandle('content');
     $data = array('content' => t("Sample Boilerplate Content"));
     $bpMC->addBlock($bt, 'Boilerplate Content', $data);
     /*
      * If you want to assign all the blocks from another page type to your
      * custom page type, this is the syntax:
      */
     //		$mc1 = CollectionType::getByHandle('left_sidebar');
     //		$mc2 = CollectionType::getByHandle('page');
     //		if (is_object($mc1) && is_object($bpMC)) {
     //			$dm = $mc1->getMasterTemplate();
     //			$blocks = $dm->getBlocks();
     //
     //			// alias these blocks to the new event calendar page
     //			foreach ($blocks as $b) {
     //				$b->alias($bpMC);
     //			}
     //		} else {
     //			if (is_object($mc2) && is_object($bpMC)) {
     //				$dm = $mc2->getMasterTemplate();
     //				$blocks = $dm->getBlocks();
     //				// alias these blocks to the new event calendar page
     //				foreach ($blocks as $b) {
     //					$b->alias($bpMC);
     //				}
     //			}
     //		}
 }
开发者ID:janzenz,项目名称:c5_boilerplate,代码行数:63,代码来源:controller.php

示例7: t

		$error[] = t("Name required.");
	}
	
	if (!$valt->validate('add_or_update_page_type')) {
		$error[] = $valt->getErrorMessage();
	}
	
	$akIDArray = $_POST['akID'];
	if (!is_array($akIDArray)) {
		$akIDArray = array();
	}
	
	if (count($error) == 0) {
		try {
			if ($_POST['task'] == 'add') {
				$nCT = CollectionType::add($_POST);
				$this->controller->redirect('/dashboard/pages/types?created=1');
			} else if (is_object($ct)) {
				$ct->update($_POST);
				$this->controller->redirect('/dashboard/pages/types?updated=1');
			}		
			exit;
		} catch(Exception $e1) {
			$error[] = $e1->getMessage();
		}
	}
}

if ($_REQUEST['created']) { 
	$message = t('Page Type added.');
} else if ($_REQUEST['updated']) {
开发者ID:notzen,项目名称:concrete5,代码行数:31,代码来源:view.php

示例8: flush

    flush();
    ob_flush();
}
// install page types
$page_type_handles = array(array('ctHandle' => 'home', 'ctName' => 'HOME'), array('ctHandle' => 'localized_home', 'ctName' => 'Localized Home'), array('ctHandle' => 'localized_projects', 'ctName' => 'Localized Projects'), array('ctHandle' => 'localized_engineers', 'ctName' => 'Localized Engineers'), array('ctHandle' => 'personal_homepage', 'ctName' => 'Personal Home'), array('ctHandle' => 'project_arena_homepage', 'ctName' => 'Arena Home'), array('ctHandle' => 'project_arena', 'ctName' => 'Arena'), array('ctHandle' => 'project_arena_subject', 'ctName' => 'Arena Subject'), array('ctHandle' => 'project_arena_zone', 'ctName' => 'Arena Zone'), array('ctHandle' => 'project_comm_forum_area', 'ctName' => 'Forum Area'), array('ctHandle' => 'project_comm_forum', 'ctName' => 'Forum'), array('ctHandle' => 'project_comm_homepage', 'ctName' => 'Community Home'), array('ctHandle' => 'project_comm_thread', 'ctName' => 'Forum Thread'), array('ctHandle' => 'project_contribute_default', 'ctName' => 'Default for Contribute'), array('ctHandle' => 'project_contribute_homepage', 'ctName' => 'Contribute Home'), array('ctHandle' => 'project_doc_homepage', 'ctName' => 'Document Home'), array('ctHandle' => 'project_doc_volume', 'ctName' => 'Document Volume'), array('ctHandle' => 'project_doc_part', 'ctName' => 'Documnet Part'), array('ctHandle' => 'project_doc_chapter', 'ctName' => 'Chapter'), array('ctHandle' => 'project_doc_all_blogs', 'ctName' => 'All Blogs'), array('ctHandle' => 'project_doc_fse_blogs', 'ctName' => 'Blog Zone'), array('ctHandle' => 'project_doc_blog', 'ctName' => 'Blog'), array('ctHandle' => 'project_download_default', 'ctName' => 'Default for Download'), array('ctHandle' => 'project_download_homepage', 'ctName' => 'Download Home'), array('ctHandle' => 'project_homepage', 'ctName' => 'Project Home'), array('ctHandle' => 'project_misc_homepage', 'ctName' => 'About'), array('ctHandle' => 'project_misc_faqs', 'ctName' => 'FAQs'), array('ctHandle' => 'project_misc_default', 'ctName' => 'Default for Misc'));
$nocache_pths = array('project_arena_homepage', 'project_arena', 'project_arena_subject', 'project_arena_zone', 'project_comm_forum_area', 'project_comm_forum', 'project_comm_homepage', 'project_comm_thread');
$short_cache_pths = array('localized_home', 'personal_homepage');
echo '<br/>';
echo 'Installing page types... <br/>';
foreach ($page_type_handles as $pth) {
    echo '	installing ' . $pth['ctHandle'] . ': ';
    $page_type = CollectionType::getByHandle($pth['ctHandle']);
    if ($page_type instanceof CollectionType) {
        echo $pth['ctHandle'] . ' had been installed; skip installing. <br/>';
    } else {
        $page_type = CollectionType::add($pth, $pkg);
        echo $pth['ctHandle'] . ' newly installed. <br/>';
        $masterCID = $page_type->getMasterCollectionID();
        $masterCollection = Page::getByID($masterCID);
        if (in_array($pth['ctHandle'], $nocache_pths)) {
            // disable full page cache for specific page types
            $masterCollection->update(array('cCacheFullPageContent' => 0));
        } else {
            if (in_array($pth['ctHandle'], $short_cache_pths)) {
                // set full page cache for specific page types
                $masterCollection->update(array('cCacheFullPageContent' => 1, 'cCacheFullPageContentOverrideLifetime' => 'custom', 'cCacheFullPageContentLifetimeCustom' => 10));
            } else {
                // follow system default for other page types
                $masterCollection->update(array('cCacheFullPageContent' => -1, 'cCacheFullPageContentOverrideLifetime' => '0', 'cCacheFullPageContentLifetimeCustom' => 0));
            }
        }
开发者ID:rratcliffe,项目名称:fsen,代码行数:31,代码来源:install.php

示例9: importPageTypesBase

	protected function importPageTypesBase(SimpleXMLElement $sx) {
		if (isset($sx->pagetypes)) {
			foreach($sx->pagetypes->pagetype as $ct) {
				$pkg = ContentImporter::getPackageObject($ct['package']);
				$ctt = CollectionType::getByHandle($ct['handle']);
				if (!is_object($ctt)) { 
					$ctr = CollectionType::add(array(
						'ctHandle' => $ct['handle'],
						'ctName' => $ct['name'],
						'ctIcon' => $ct['icon'],
						'ctIsInternal' => (string) $ct['internal']
					), $pkg);
				}
			}
		}
	}
开发者ID:nveid,项目名称:concrete5,代码行数:16,代码来源:importer.php


注:本文中的CollectionType::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。