本文整理汇总了PHP中CollectionAttributeKey::add方法的典型用法代码示例。如果您正苦于以下问题:PHP CollectionAttributeKey::add方法的具体用法?PHP CollectionAttributeKey::add怎么用?PHP CollectionAttributeKey::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CollectionAttributeKey
的用法示例。
在下文中一共展示了CollectionAttributeKey::add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: installOrUpgrade
private function installOrUpgrade($pkg, $fromVersion)
{
$at = AttributeType::getByHandle('handle_https');
if (!is_object($at)) {
$at = AttributeType::add('handle_https', tc('AttributeTypeName', 'HTTPS handling'), $pkg);
}
$akc = AttributeKeyCategory::getByHandle('collection');
if (is_object($akc)) {
if (!$akc->hasAttributeKeyTypeAssociated($at)) {
$akc->associateAttributeKeyType($at);
}
}
if (empty($fromVersion)) {
$ak = CollectionAttributeKey::getByHandle('handle_https');
if (!is_object($ak)) {
$hhh = Loader::helper('https_handling', 'handle_https');
/* @var $hhh HttpsHandlingHelper */
$httpDomain = defined('BASE_URL') ? BASE_URL : Config::get('BASE_URL');
if (!$httpDomain) {
$httpDomain = 'http://' . $hhh->getRequestDomain();
}
$httpsDomain = defined('BASE_URL_SSL') ? BASE_URL_SSL : Config::get('BASE_URL_SSL');
if (!$httpsDomain) {
$httpsDomain = 'https://' . $hhh->getRequestDomain();
}
$ak = CollectionAttributeKey::add($at, array('akHandle' => 'handle_https', 'akName' => tc('AttributeKeyName', 'Page HTTP/HTTPS'), 'akIsSearchable' => 1, 'akIsSearchableIndexed' => 1, 'akIsAutoCreated' => 1, 'akIsEditable' => 1, 'akIsInternal' => 0, 'akEnabled' => 0, 'akDefaultRequirement' => HttpsHandlingHelper::SSLHANDLING_DOESNOT_MATTER, 'akCustomDomains' => 0, 'akHTTPDomain' => $httpDomain, 'akHTTPSDomain' => $httpsDomain), $pkg);
}
}
}
示例2: run
public function run() {
$db = Loader::db();
Loader::model('collection_attributes');
Loader::model('single_page');
Loader::model('file_version');
// Add in stuff that may have gotten missed before
$p = Page::getByPath('/profile');
if ($p->isError()) {
$d1 = SinglePage::add('/profile');
$d2 = SinglePage::add('/profile/edit');
$d3 = SinglePage::add('/profile/avatar');
}
$p2 = Page::getByPath('/dashboard/users/registration');
if ($p2->isError()) {
$d4 = SinglePage::add('/dashboard/users/registration');
}
// Move any global blocks to new scrapbook page.
$sc = Page::getByPath("/dashboard/scrapbook/global");
$scn = Page::getByPath('/dashboard/scrapbook');
$scu = Page::getByPath('/dashboard/scrapbook/user');
if (!$sc->isError()) {
$blocks = $sc->getBlocks("Global Scrapbook");
if (count($blocks) > 0) {
// we create the new shared scrapbook 1
$a = Area::getOrCreate($scn, t('Shared Scrapbook 1'));
foreach($blocks as $_b) {
// we move them into the area on the new page.
$_b->move($scn, $a);
$_b->refreshCacheAll();
}
}
$sc->delete();
}
if (!$scu->isError()) {
$scu->delete();
}
//add the new collection attribute keys
$cak=CollectionAttributeKey::getByHandle('header_extra_content');
if(!is_object($cak)) {
CollectionAttributeKey::add('header_extra_content', t('Header Extra Content'), true, null, 'TEXT');
}
$cak=CollectionAttributeKey::getByHandle('exclude_search_index');
if (!is_object($cak)) {
CollectionAttributeKey::add('exclude_search_index', t('Exclude From Search Index'), true, null, 'BOOLEAN');
}
//convert file tags to new format, cleaned up with leading and trailing line breaks
$fileVersionsData=$db->GetAll('SELECT fID, fvID, fvTags FROM FileVersions');
foreach($fileVersionsData as $fvData){
$vals=array( FileVersion::cleanTags($fvData['fvTags']) , $fvData['fID'] , $fvData['fvID'] );
$db->query('UPDATE FileVersions SET fvTags=? WHERE fID=? AND fvID=?', $vals );
}
}
示例3: add
public function add()
{
$this->select_type();
$type = $this->get('type');
$cnt = $type->getController();
$e = $cnt->validateKey($this->post());
if ($e->has()) {
$this->set('error', $e);
} else {
$type = AttributeType::getByID($this->post('atID'));
$ak = CollectionAttributeKey::add($type, $this->post());
$this->redirect('/dashboard/pages/attributes/', 'attribute_created');
}
}
示例4: install
public function install()
{
$pkg = parent::install();
Loader::model('single_page');
Loader::model('attribute/categories/collection');
// install attributes
$cab1 = CollectionAttributeKey::add('BOOLEAN', array('akHandle' => 'easynews_section', 'akName' => t('NEWS Section'), 'akIsSearchable' => true), $pkg);
//install pages
$def = SinglePage::add('/dashboard/easy_news', $pkg);
$def->update(array('cName' => 'Easy News', 'cDescription' => t('Manage site news.')));
$def = SinglePage::add('/dashboard/easy_news/help', $pkg);
$def->update(array('cName' => 'Easy News Help', 'cDescription' => t('Easy News help.')));
//install block
BlockType::installBlockTypeFromPackage('easynews_list', $pkg);
}
示例5: add
public function add()
{
$this->select_type();
$type = $this->get('type');
$cnt = $type->getController();
$e = $cnt->validateKey($this->post());
if ($e->has()) {
$this->set('error', $e);
} else {
$type = AttributeType::getByID($this->post('atID'));
$args = array('akHandle' => $this->post('akHandle'), 'akName' => $this->post('akName'), 'akIsSearchable' => $this->post('akIsSearchable'), 'akIsSearchableIndexed' => $this->post('akIsSearchableIndexed'), 'akIsAutoCreated' => 0, 'akIsEditable' => 1);
$ak = CollectionAttributeKey::add($type, $this->post());
$this->redirect('/dashboard/pages/attributes/', 'attribute_created');
}
}
示例6: run
public function run()
{
$db = Loader::db();
Cache::disableLocalCache();
Loader::model('attribute/categories/collection');
$cak = CollectionAttributeKey::getByHandle('exclude_page_list');
if (!is_object($cak)) {
$boolt = AttributeType::getByHandle('boolean');
$cab4b = CollectionAttributeKey::add($boolt, array('akHandle' => 'exclude_page_list', 'akName' => t('Exclude From Page List'), 'akIsSearchable' => true));
Loader::model('page_list');
$pl = new PageList();
$pl->filterByExcludeNav(1);
$list = $pl->get();
foreach ($list as $c) {
$c->setAttribute('exclude_page_list', 1);
$c->reindex();
}
}
Cache::enableLocalCache();
}
示例7: install
public function install()
{
$pkg = parent::install();
Loader::model('single_page');
$single_page = SinglePage::add('/dashboard/wordpress_import', $pkg);
$single_page->update(array('cName' => t('WordPress Import'), 'cDescription' => t('Import WordPress Sites')));
$import_stuff = SinglePage::add('/dashboard/wordpress_import/import', $pkg);
$import_stuff->update(array('cName' => t('Import')));
$import_stuff = SinglePage::add('/dashboard/wordpress_import/file', $pkg);
$import_stuff->update(array('cName' => t('File')));
$select = AttributeType::getByHandle('select');
$wpCategory = CollectionAttributeKey::getByHandle('wordpress_category');
if (!$wpCategory instanceof CollectionAttributeKey) {
$wpCategory = CollectionAttributeKey::add($select, array('akSelectAllowMultipleValues' => 1, 'akSelectOptionDisplayOrder' => 'popularity_desc', 'akSelectAllowOtherValues' => 1, 'akHandle' => 'wordpress_category', 'akName' => t('Wordpress Category')), $pkg);
}
$tags = CollectionAttributeKey::getByHandle('tags');
if (!$tags instanceof CollectionAttributeKey) {
$tags = CollectionAttributeKey::add($select, array('akSelectAllowMultipleValues' => 1, 'akSelectOptionDisplayOrder' => 'popularity_desc', 'akSelectAllowOtherValues' => 1, 'akHandle' => 'tagsy', 'akName' => t('Tags')), $pkg);
}
$co = new Config();
$co->setPackageObject($pkg);
$co->save("WORDPRESS_IMPORT_FID", 0);
}
示例8: setupDashboardIcons
protected function setupDashboardIcons()
{
$cak = CollectionAttributeKey::getByHandle('icon_dashboard');
if (!is_object($cak)) {
$textt = AttributeType::getByHandle('text');
$cab4b = CollectionAttributeKey::add($textt, array('akHandle' => 'icon_dashboard', 'akName' => t('Dashboard Icon'), 'akIsInternal' => true));
}
$iconArray = array('/dashboard/composer/write' => 'icon-pencil', '/dashboard/composer/drafts' => 'icon-book', '/dashboard/sitemap/full' => 'icon-home', '/dashboard/sitemap/explore' => 'icon-road', '/dashboard/sitemap/search' => 'icon-search', '/dashboard/files/search' => 'icon-picture', '/dashboard/files/attributes' => 'icon-cog', '/dashboard/files/sets' => 'icon-list-alt', '/dashboard/files/add_set' => 'icon-plus-sign', '/dashboard/users/search' => 'icon-user', '/dashboard/users/groups' => 'icon-globe', '/dashboard/users/attributes' => 'icon-cog', '/dashboard/users/add' => 'icon-plus-sign', '/dashboard/users/add_group' => 'icon-plus', '/dashboard/users/group_sets' => 'icon-list', '/dashboard/reports/statistics' => 'icon-signal', '/dashboard/reports/forms' => 'icon-briefcase', '/dashboard/reports/surveys' => 'icon-tasks', '/dashboard/reports/logs' => 'icon-time', '/dashboard/pages/themes' => 'icon-font', '/dashboard/pages/types' => 'icon-file', '/dashboard/pages/attributes' => 'icon-cog', '/dashboard/pages/single' => 'icon-wrench', '/dashboard/workflow/list' => 'icon-list', '/dashboard/workflow/me' => 'icon-user', '/dashboard/blocks/stacks' => 'icon-th', '/dashboard/blocks/permissions' => 'icon-lock', '/dashboard/blocks/types' => 'icon-wrench');
foreach ($iconArray as $path => $icon) {
$sp = Page::getByPath($path);
if (is_object($sp) && !$sp->isError()) {
$sp->setAttribute('icon_dashboard', $icon);
}
}
}
示例9: upgradeCollectionAttributes
protected function upgradeCollectionAttributes() {
$messages = array();
$db = Loader::db();
$r = $db->Execute('select _CollectionAttributeKeys.* from _CollectionAttributeKeys order by _CollectionAttributeKeys.akID asc');
while ($row = $r->FetchRow()) {
$cleanHandle = preg_replace("/[^A-Za-z0-9\_]/",'',$row['akHandle']); // remove spaces, chars that'll mess up our index tables
$existingAKID = $db->GetOne('select akID from AttributeKeys where akHandle = ?', array($cleanHandle) );
if ($existingAKID < 1) {
$args = array(
'akHandle' => $cleanHandle,
'akIsSearchable' => $row['akSearchable'],
'akName' => $row['akName']
);
$sttype = $row['akType'];
switch($row['akType']) {
case 'SELECT':
if ($row['akAllowOtherValues']) {
$args['akSelectAllowMultipleValues'] = 1;
}
break;
case 'SELECT_MULTIPLE':
$sttype = 'SELECT';
$args['akSelectAllowMultipleValues'] = 1;
if ($row['akAllowOtherValues']) {
$args['akSelectAllowMultipleValues'] = 1;
}
break;
}
$type = AttributeType::getByHandle(strtolower($sttype));
$ak = CollectionAttributeKey::add($type, $args);
if ($sttype == 'SELECT') {
$selectOptions = explode("\n", $row['akValues']);
foreach($selectOptions as $so) {
if ($so != '') {
SelectAttributeTypeOption::add($ak, $so);
}
}
}
} else {
$ak = CollectionAttributeKey::getByID($existingAKID);
}
$r2 = $db->Execute('select * from _CollectionAttributeValues where akID = ? and isImported = 0', $row['akID']);
while ($row2 = $r2->FetchRow()) {
try {
$nc = Page::getByID($row2['cID'], $row2['cvID']);
$value = $row2['value'];
if ($row['akType'] == 'SELECT' || $row['akType'] == 'SELECT_MULTIPLE') {
$value = explode("\n", $value);
$nc->setAttribute($ak, $value);
} else if ($row['akType'] == 'IMAGE_FILE') {
$value = File::getByID($value);
if (is_object($value) && $value->getFileID() > 0) {
$nc->setAttribute($ak, $value);
}
} else {
$nc->setAttribute($ak, $value);
}
unset($nc);
$db->Execute('update _CollectionAttributeValues set isImported = 1 where akID = ? and cvID = ? and cID = ?', array($row['akID'], $row2['cvID'], $row2['cID']));
$this->incrementImported();
} catch (Exception $e) {
$messages[] = t('Error while converting the attributes on cID: %s Error:<br/>%s', $row2['cID'], $e->getMessage());
continue;
}
}
unset($ak);
unset($row2);
$r2->Close();
unset($r2);
}
unset($row);
$r->Close();
unset($r);
return $messages;
}
示例10: upgrade
public function upgrade()
{
parent::upgrade();
$pkg = Package::getByHandle($this->pkgHandle);
//@todo write conversion from lang to locale
//1.0 - 1.1 changed languaage to locale
$db = Loader::db();
// update the MultilingualSections table
$rows = $db->getAll("SELECT * FROM MultilingualSections");
if (is_array($rows) && count($rows)) {
foreach ($rows as $r) {
if (strlen($r['msLanguage']) && !strlen($r['msLocale'])) {
$locale = $r['msLanguage'] . (strlen($r['msIcon']) ? "_" . $r['msIcon'] : "");
$db->query("UPDATE MultilingualSections SET msLocale = ? WHERE cID = ?", array($locale, $r['cID']));
}
}
}
// install job
Loader::model('job');
$jb = Job::installByPackage('generate_multilingual_sitemap', $pkg);
// update the MultilingualPageRelations table
$hasLocales = $db->getOne("SELECT COUNT(msLocale) FROM MultilingualSections WHERE LENGTH(msLocale)");
if (!$hasLocales) {
$query = "UPDATE MultilingualPageRelations mpr, MultilingualSections \n\t\t\t\tSET mpr.mpLocale = MultilingualSections.msLocale\n\t\t\t\tWHERE mpr.mpLanguage = MultilingualSections.msLanguage";
$db->query($query);
}
// 1.1.2
$ak = CollectionAttributeKey::getByHandle('multilingual_exclude_from_copy');
if (!is_object($ak)) {
CollectionAttributeKey::add('BOOLEAN', array('akHandle' => 'multilingual_exclude_from_copy', 'akName' => t('Exclude from Internationalization Copy'), 'akIsSearchable' => true), $pkg);
}
}