本文整理汇总了PHP中CollectionAttributeKey::getByHandle方法的典型用法代码示例。如果您正苦于以下问题:PHP CollectionAttributeKey::getByHandle方法的具体用法?PHP CollectionAttributeKey::getByHandle怎么用?PHP CollectionAttributeKey::getByHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CollectionAttributeKey
的用法示例。
在下文中一共展示了CollectionAttributeKey::getByHandle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: _setupDashboardIcon
private function _setupDashboardIcon($page, $icon)
{
$cak = CollectionAttributeKey::getByHandle('icon_dashboard');
if (is_object($cak)) {
$page->setAttribute('icon_dashboard', $icon);
}
}
示例3: getPages
function getPages($query = null)
{
Loader::model('page_list');
$db = Loader::db();
$bID = $this->bID;
if ($this->bID) {
$q = "select * from btDateNav where bID = '{$bID}'";
$r = $db->query($q);
if ($r) {
$row = $r->fetchRow();
}
} else {
$row['num'] = $this->num;
$row['cParentID'] = $this->cParentID;
$row['cThis'] = $this->cThis;
$row['orderBy'] = $this->orderBy;
$row['ctID'] = $this->ctID;
$row['rss'] = $this->rss;
}
$pl = new PageList();
$pl->setNameSpace('b' . $this->bID);
$cArray = array();
//$pl->sortByPublicDate();
$pl->sortByPublicDateDescending();
$num = (int) $row['num'];
if ($num > 0) {
$pl->setItemsPerPage($num);
}
$c = $this->getCollectionObject();
if (is_object($c)) {
$this->cID = $c->getCollectionID();
}
$cParentID = $row['cThis'] ? $this->cID : $row['cParentID'];
if ($this->displayFeaturedOnly == 1) {
Loader::model('attribute/categories/collection');
$cak = CollectionAttributeKey::getByHandle('is_featured');
if (is_object($cak)) {
$pl->filterByIsFeatured(1);
}
}
$pl->filter('cvName', '', '!=');
if ($row['ctID']) {
$pl->filterByCollectionTypeID($row['ctID']);
}
$pl->filterByAttribute('exclude_nav', false);
if ($row['cParentID'] != 0) {
$pl->filterByParentID($cParentID);
}
if ($num > 0) {
$pages = $pl->getPage();
} else {
$pages = $pl->get();
}
$this->set('pl', $pl);
return $pages;
}
示例4: testUnsetCommonAttributes
/**
* @dataProvider commonAttributeHandles
*/
public function testUnsetCommonAttributes($handle)
{
$page = Page::getByPath('/about');
$ak = CollectionAttributeKey::getByHandle($handle);
$page->clearAttribute($ak);
$cav = $page->getAttributeValueObject($ak);
if (is_object($cav)) {
$this->fail(t("Page::clearAttribute did not delete '%s'.", $handle));
}
}
示例5: 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 );
}
}
示例6: import_wordpress_xml
public function import_wordpress_xml()
{
if ($this->post('import-images') == 'on') {
$this->importImages = true;
$filesetname;
$this->post('file-set-name') ? $this->filesetname = $this->post('file-set-name') : ($this->filesetname = t("Imported Wordpress Files"));
$this->createFileSet = true;
}
$pages = array();
if (intval($this->post('wp-file')) > 0) {
Loader::model('file');
$co = new Config();
$pkg = Package::getByHandle('wordpress_site_importer');
$co->setPackageObject($pkg);
$co->save("WORDPRESS_IMPORT_FID", $this->post('wp-file'));
$importFile = File::getByID($this->post('wp-file'));
$nv = $importFile->getVersion();
$fileUrl = $nv->getDownloadURL();
$xml = @simplexml_load_file($fileUrl, "SimpleXMLElement", LIBXML_NOCDATA);
$items = array();
foreach ($xml->channel->item as $item) {
$items[] = $item->asxml();
}
$db = Loader::db();
$sql = $db->Prepare('insert into WordpressItems (wpItem) values(?)');
foreach ($items as $item) {
$db->Execute($sql, $item);
}
$categories = array();
$namespaces = $xml->getDocNamespaces();
foreach ($xml->xpath('/rss/channel/wp:category') as $term_arr) {
$t = $term_arr->children($namespaces['wp']);
$categories[] = array('term_id' => (int) $t->term_id, 'category_nicename' => (string) $t->category_nicename, 'category_parent' => (string) $t->category_parent, 'cat_name' => (string) $t->cat_name, 'category_description' => (string) $t->category_description);
}
Loader::model('attribute/categories/collection');
$akt = CollectionAttributeKey::getByHandle("wordpress_category");
for ($i = 0; $i < count($categories); $i++) {
$opt = new SelectAttributeTypeOption(0, $categories[$i]['cat_name'], $i);
$opt = $opt->saveOrCreate($akt);
}
foreach ($xml->xpath('/rss/channel/wp:tag') as $term_arr) {
$t = $term_arr->children($namespaces['wp']);
$tags[] = array('term_id' => (int) $t->term_id, 'tag_slug' => (string) $t->tag_slug, 'tag_name' => (string) $t->tag_name, 'tag_description' => (string) $t->tag_description);
}
$akt = CollectionAttributeKey::getByHandle("tags");
for ($i = 0; $i < count($tags); $i++) {
$opt = new SelectAttributeTypeOption(0, $tags[$i]['tag_name'], $i);
$opt = $opt->saveOrCreate($akt);
}
} else {
echo t("No file");
exit;
}
$this->view();
}
示例7: setAuthor
public function setAuthor($p)
{
$ak = CollectionAttributeKey::getByHandle('blog_author');
if ($this->wp_post->author) {
Loader::model('userinfo');
$ui = UserInfo::getByUserName($this->wp_post->author);
if (is_object($ui)) {
$p->setAttribute($ak, $ui->getUserID());
}
}
}
示例8: run
/** Executes the job.
* @return string Returns a string describing the job result in case of success.
* @throws Exception Throws an exception in case of errors.
*/
public function run()
{
Cache::disableCache();
Cache::disableLocalCache();
try {
$db = Loader::db();
$instances = array('navigation' => Loader::helper('navigation'), 'dashboard' => Loader::helper('concrete/dashboard'), 'view_page' => PermissionKey::getByHandle('view_page'), 'guestGroup' => Group::getByID(GUEST_GROUP_ID), 'now' => new DateTime('now'), 'ak_exclude_sitemapxml' => CollectionAttributeKey::getByHandle('exclude_sitemapxml'), 'ak_sitemap_changefreq' => CollectionAttributeKey::getByHandle('sitemap_changefreq'), 'ak_sitemap_priority' => CollectionAttributeKey::getByHandle('sitemap_priority'));
$instances['guestGroupAE'] = array(GroupPermissionAccessEntity::getOrCreate($instances['guestGroup']));
$xmlDoc = new SimpleXMLElement('<' . '?xml version="1.0" encoding="' . APP_CHARSET . '"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />');
$rs = Loader::db()->Query('SELECT cID FROM Pages');
while ($row = $rs->FetchRow()) {
self::addPage($xmlDoc, intval($row['cID']), $instances);
}
$rs->Close();
Events::fire('on_sitemap_xml_ready', $xmlDoc);
$dom = dom_import_simplexml($xmlDoc)->ownerDocument;
$dom->formatOutput = true;
$addedPages = count($xmlDoc->url);
$relName = ltrim(SITEMAPXML_FILE, '\\/');
$osName = rtrim(DIR_BASE, '\\/') . '/' . $relName;
$urlName = rtrim(BASE_URL . DIR_REL, '\\/') . '/' . $relName;
if (!file_exists($osName)) {
@touch($osName);
}
if (!is_writable($osName)) {
throw new Exception(t('The file %s is not writable', $osName));
}
if (!($hFile = @fopen($osName, 'w'))) {
throw new Exception(t('Cannot open file %s', $osName));
}
if (!@fwrite($hFile, $dom->saveXML())) {
throw new Exception(t('Error writing to file %s', $osName));
}
@fflush($hFile);
@fclose($hFile);
unset($hFile);
return t('%1$s file saved (%2$d pages).', sprintf('<a href="%s" target="_blank">%s</a>', $urlName, preg_replace('/^https?:\\/\\//i', '', $urlName)), $addedPages);
} catch (Exception $x) {
if (isset($hFile) && $hFile) {
@fflush($hFile);
@ftruncate($hFile, 0);
@fclose($hFile);
$hFile = null;
}
throw $x;
}
}
示例9: getSelectOptions
/**
* Looks up the list of options from the DB
* This is the only place where themes are 'categorized', which is purely for presentation in the walk create form
*
* @param string $type Which type of tag to return (e.g. theme, accessible)
* @return array
*/
public static function getSelectOptions($type = 'all')
{
$options = array();
$satc = new SelectAttributeTypeController(AttributeType::getByHandle('select'));
if ($type === 'all' || $type === 'theme') {
$satc->setAttributeKey(CollectionAttributeKey::getByHandle('theme'));
$themeAK = CollectionAttributeKey::getByHandle('theme');
foreach ($satc->getOptions() as $v) {
$category = $this->getCategory($v->value);
$options['theme'][$category][] = ['handle' => $v->value, 'name' => self::getName($v->value)];
}
}
if ($type === 'all' || $type === 'accessibile') {
$satc->setAttributeKey(CollectionAttributeKey::getByHandle('accessible'));
foreach ($satc->getOptions() as $v) {
$options['accessible'][] = ['handle' => $v->value, 'name' => self::getName($v->value)];
}
}
return $options;
}
示例10: 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();
}
示例11: getAttribute
public function getAttribute($ak, $c, $displayMode = false)
{
if (is_object($ak)) {
$akHandle = $ak->getAttributeKeyHandle();
} else {
$akHandle = $ak;
$ak = null;
}
$akHash = $akHandle . ':' . $displayMode;
if (!isset($this->attributes[$akHash])) {
$this->attributes[$akHash] = false;
if (!$ak) {
$ak = CollectionAttributeKey::getByHandle($akHandle);
}
if (is_object($ak)) {
$av = $c->getAttributeValueObject($ak);
if (is_object($av)) {
$this->attributes[$akHash] = $av->getValue($displayMode);
}
}
}
return $this->attributes[$akHash];
}
示例12: 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);
}
示例13: loadAttribute
protected function loadAttribute()
{
Loader::model('attribute/categories/collection');
$ak = CollectionAttributeKey::getByHandle($this->attributeHandle);
return $ak;
}
示例14: defined
<?php
defined('C5_EXECUTE') or die("Access Denied.");
?>
<?php
// grab all tags in use based on the path
$ak = CollectionAttributeKey::getByHandle('tags');
$akc = $ak->getController();
$pp = false;
$tagCounts = array();
if ($baseSearchPath != '') {
$pp = Page::getByPath($baseSearchPath);
}
$ttags = $akc->getOptionUsageArray($pp);
$tags = array();
foreach ($ttags as $t) {
$tagCounts[] = $t->getSelectAttributeOptionUsageCount();
$tags[] = $t;
}
shuffle($tags);
$tagSizes = array();
$count = count($tagCounts);
foreach ($tagCounts as $tagCount => $pos) {
$tagSizes[$pos] = setFontPx(($pos + 1) / $count);
}
function setFontPx($weight)
{
$tagMinFontPx = 10;
$tagMaxFontPx = 24;
$em = $weight * ($tagMaxFontPx - $tagMinFontPx) + $tagMinFontPx;
示例15: 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);
}
}
}