本文整理汇总了PHP中CollectionAttributeKey::getByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CollectionAttributeKey::getByID方法的具体用法?PHP CollectionAttributeKey::getByID怎么用?PHP CollectionAttributeKey::getByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CollectionAttributeKey
的用法示例。
在下文中一共展示了CollectionAttributeKey::getByID方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public function edit($akID = 0)
{
if ($this->post('akID')) {
$akID = $this->post('akID');
}
$key = CollectionAttributeKey::getByID($akID);
if (!is_object($key) || $key->isAttributeKeyInternal()) {
$this->redirect('/dashboard/pages/attributes');
}
$type = $key->getAttributeType();
$this->set('key', $key);
$this->set('type', $type);
if ($this->isPost()) {
$cnt = $type->getController();
$cnt->setAttributeKey($key);
$e = $cnt->validateKey($this->post());
if ($e->has()) {
$this->set('error', $e);
} else {
$type = AttributeType::getByID($this->post('atID'));
$key->update($this->post());
$this->redirect('/dashboard/pages/attributes/', 'attribute_updated');
}
}
}
示例2: do_search
public function do_search()
{
$q = $_REQUEST['query'];
$_q = $q;
Loader::library('database_indexed_search');
$ipl = new IndexedPageList();
$aksearch = false;
$ipl->ignoreAliases();
if (is_array($_REQUEST['akID'])) {
Loader::model('attribute/categories/collection');
foreach ($_REQUEST['akID'] as $akID => $req) {
$fak = CollectionAttributeKey::getByID($akID);
if (is_object($fak)) {
$type = $fak->getAttributeType();
$cnt = $type->getController();
$cnt->setAttributeKey($fak);
$cnt->searchForm($ipl);
$aksearch = true;
}
}
}
if (isset($_REQUEST['month']) && isset($_REQUEST['year'])) {
$month = strtotime($_REQUEST['year'] . '-' . $_REQUEST['month'] . '-01');
$month = date('Y-m-', $month);
$ipl->filterByPublicDate($month . '%', 'like');
$aksearch = true;
}
if (empty($_REQUEST['query']) && $aksearch == false) {
return false;
}
$ipl->setSimpleIndexMode(true);
if (isset($_REQUEST['query'])) {
$ipl->filterByKeywords($_q);
}
if (is_array($_REQUEST['search_paths'])) {
foreach ($_REQUEST['search_paths'] as $path) {
if (!strlen($path)) {
continue;
}
$ipl->filterByPath($path);
}
} elseif ($this->baseSearchPath != '') {
$ipl->filterByPath($this->baseSearchPath);
}
$ipl->filter(false, '(ak_exclude_page_list = 0 or ak_exclude_page_list is null)');
$ipl->filter(false, '(ak_exclude_search_index = 0 or ak_exclude_search_index is null)');
$ipl->setItemsPerPage(5);
$res = $ipl->getPage();
foreach ($res as $r) {
$results[] = new IndexedSearchResult($r['cID'], $r['cName'], $r['cDescription'], $r['score'], $r['cPath'], $r['content']);
}
$this->set('query', $q);
$this->set('paginator', $ipl->getPagination());
$this->set('results', $results);
$this->set('do_search', true);
$this->set('searchList', $ipl);
}
示例3: processMetaData
function processMetaData($nvc){
Loader::model('collection_attributes');
$nvc->clearCollectionAttributes($_POST['selectedAKIDs']);
if (is_array($_POST['selectedAKIDs'])) {
foreach($_POST['selectedAKIDs'] as $akID) {
if ($akID > 0) {
$ak = CollectionAttributeKey::getByID($akID);
$ak->saveAttributeForm($nvc);
}
}
}
}
示例4: edit
public function edit($akID = 0)
{
if ($this->post('akID')) {
$akID = $this->post('akID');
}
$key = CollectionAttributeKey::getByID($akID);
$type = $key->getAttributeType();
$this->set('key', $key);
$this->set('type', $type);
if ($this->isPost()) {
$cnt = $type->getController();
$cnt->setAttributeKey($key);
$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);
$key->update($this->post());
$this->redirect('/dashboard/pages/attributes/', 'attribute_updated');
}
}
}
示例5: getComposerContentItems
public function getComposerContentItems()
{
$db = Loader::db();
$r = $db->Execute('select bID, akID, ccFilename from ComposerContentLayout where ctID = ? order by displayOrder asc', array($this->ctID));
$items = array();
while ($row = $r->FetchRow()) {
if ($row['akID'] > 0) {
$obj = CollectionAttributeKey::getByID($row['akID']);
if (is_object($obj)) {
$items[] = $obj;
}
} else {
if ($row['bID'] > 0) {
$b = Block::getByID($row['bID']);
if (is_object($b)) {
$items[] = $b;
}
}
}
}
return $items;
}
示例6: get
/**
* @access private
*/
public function get($akID)
{
return CollectionAttributeKey::getByID($akID);
}
示例7: do_search
function do_search() {
$q = $_REQUEST['query'];
// i have NO idea why we added this in rev 2000. I think I was being stupid. - andrew
// $_q = trim(preg_replace('/[^A-Za-z0-9\s\']/i', ' ', $_REQUEST['query']));
$_q = $q;
Loader::library('database_indexed_search');
$ipl = new IndexedPageList();
$aksearch = false;
if (is_array($_REQUEST['akID'])) {
Loader::model('attribute/categories/collection');
foreach($_REQUEST['akID'] as $akID => $req) {
$fak = CollectionAttributeKey::getByID($akID);
if (is_object($fak)) {
$type = $fak->getAttributeType();
$cnt = $type->getController();
$cnt->setAttributeKey($fak);
$cnt->searchForm($ipl);
$aksearch = true;
}
}
}
if (empty($_REQUEST['query']) && $aksearch == false) {
return false;
}
$ipl->setSimpleIndexMode(true);
if (isset($_REQUEST['query'])) {
$ipl->filterByKeywords($_q);
}
if( is_array($_REQUEST['search_paths']) ){
foreach($_REQUEST['search_paths'] as $path) {
if(!strlen($path)) continue;
$ipl->filterByPath($path);
}
}
$res = $ipl->getPage();
foreach($res as $r) {
$results[] = new IndexedSearchResult($r['cID'], $r['cName'], $r['cDescription'], $r['score'], $r['cPath'], $r['content']);
}
$this->set('query', $q);
$this->set('paginator', $ipl->getPagination());
$this->set('results', $results);
$this->set('do_search', true);
}
示例8: t
if ($newPostSettings['display_image']) {
?>
<div class="form-group forumImage">
<label for="forumImage"><?php
echo t('Forum Image');
?>
</label>
<?php
echo $al->file('newForumImage', 'forumImage', t('Choose Image'));
?>
</div>
<?php
}
if ($optionalAttributes) {
foreach ($optionalAttributes as $optAtt) {
$ak = CollectionAttributeKey::getByID($optAtt);
if (is_object($ak)) {
if ($ak->atHandle != 'boolean') {
?>
<label><?php
echo $ak->getAttributeKeyName();
?>
</label>
<?php
}
echo $ak->render('form');
echo '<br/>';
}
}
}
if ($newPostSettings['display_tags']) {
示例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: getSetCollectionAttributes
public function getSetCollectionAttributes() {
$db = Loader::db();
$akIDs = $db->GetCol("select akID from CollectionAttributeValues where cID = ? and cvID = ?", array($this->getCollectionID(), $this->getVersionID()));
$attribs = array();
foreach($akIDs as $akID) {
$attribs[] = CollectionAttributeKey::getByID($akID);
}
return $attribs;
}
示例11: delete
function delete()
{
$db = Loader::db();
$cvID = $this->cvID;
$c = Page::getByID($this->cID, $cvID);
$cID = $c->getCollectionID();
$q = "select bID, arHandle from CollectionVersionBlocks where cID = '{$cID}' and cvID='{$cvID}'";
$r = $db->query($q);
if ($r) {
while ($row = $r->fetchRow()) {
if ($row['bID']) {
$b = Block::getByID($row['bID'], $c, $row['arHandle']);
if (is_object($b)) {
$b->deleteBlock();
}
}
unset($b);
}
}
$r = $db->Execute('select avID, akID from CollectionAttributeValues where cID = ? and cvID = ?', array($cID, $cvID));
Loader::model('attribute/categories/collection');
while ($row = $r->FetchRow()) {
$cak = CollectionAttributeKey::getByID($row['akID']);
$cav = $c->getAttributeValueObject($cak);
if (is_object($cav)) {
$cav->delete();
}
}
$db->Execute('delete from CollectionVersionBlockStyles where cID = ? and cvID = ?', array($cID, $cvID));
$db->Execute('delete from CollectionVersionAreaStyles where cID = ? and cvID = ?', array($cID, $cvID));
$db->Execute('delete from CollectionVersionAreaLayouts where cID = ? and cvID = ?', array($cID, $cvID));
$q = "delete from CollectionVersions where cID = '{$cID}' and cvID='{$cvID}'";
$r = $db->query($q);
$this->refreshCache();
}
示例12: array_diff
// do I have the ability to edit this attribute?
if (in_array($ak->getAttributeKeyID(), $asl->getAttributesAllowedArray())) {
// Is this item in the selectedAKIDs array? If so then it is being saved
if (in_array($ak->getAttributeKeyID(), $_POST['selectedAKIDs'])) {
$ak->saveAttributeForm($nvc);
} else {
// it is being removed
$nvc->clearAttribute($ak);
}
$processedAttributes[] = $ak->getAttributeKeyID();
}
}
$newAttributes = array_diff($selectedAKIDs, $processedAttributes);
foreach ($newAttributes as $akID) {
if ($akID > 0 && in_array($akID, $asl->getAttributesAllowedArray())) {
$ak = CollectionAttributeKey::getByID($akID);
$ak->saveAttributeForm($nvc);
}
}
$obj = new stdClass();
if (($_POST['rel'] == 'SITEMAP' || $_POST['approveImmediately']) && $cp->canApprovePageVersions()) {
$pkr = new ApprovePagePageWorkflowRequest();
$u = new User();
$pkr->setRequestedPage($c);
$v = CollectionVersion::get($c, "RECENT");
$pkr->setRequestedVersionID($v->getVersionID());
$pkr->setRequesterUserID($u->getUserID());
$u->unloadCollectionEdit($c);
$response = $pkr->trigger();
$obj->rel = $_POST['rel'];
$obj->name = $v->getVersionName();
示例13: getAvailableAttributeKeys
public function getAvailableAttributeKeys()
{
if (count($akIDArray) == 0) {
$this->populateAvailableAttributeKeys();
}
$objArray = array();
foreach ($this->akIDArray as $akID) {
$obj = CollectionAttributeKey::getByID($akID);
if (is_object($obj)) {
$objArray[] = $obj;
}
}
return $objArray;
}
示例14: handleRequest
/**
* @param Page|View|Collection $page
* @param User $user
*/
public static function handleRequest($page)
{
if (!is_object($page)) {
return;
}
if (is_a($page, 'View')) {
$page = $page->getCollectionObject();
}
if (!is_object($page) || !is_a($page, 'Collection') || $page->isError()) {
return;
}
$db = Loader::db();
$ak = null;
$config = null;
$rs = $db->Query('select * from atHandleHttpsConfig where akEnabled = 1');
while ($row = $rs->FetchRow()) {
$ak = CollectionAttributeKey::getByID($row['akID']);
if (is_object($ak)) {
$config = $row;
break;
}
}
$rs->Close();
if (!is_object($ak)) {
return;
}
$akPage = $page;
for (;;) {
$handling = $akPage->getAttribute($ak);
if (!(is_string($handling) && strlen($handling))) {
$handling = $row['akDefaultRequirement'];
if (!(is_string($handling) && strlen($handling))) {
return;
}
}
if ($handling !== self::SSLHANDLING_INHERIT) {
break;
}
$cID = $akPage->getCollectionID();
if (empty($cID) || $cID == HOME_CID) {
break;
}
if (!is_a($akPage, 'Page')) {
// Need to load the Page object associated to the Collection object we received
$akPage = Page::getByID($cID, 'ACTIVE');
if (!is_object($akPage)) {
break;
}
}
$parentCID = $akPage->getCollectionParentID();
if (empty($parentCID)) {
break;
}
$akPage = Page::getByID($parentCID, 'ACTIVE');
if (!is_object($akPage) || $akPage->isError()) {
break;
}
}
$switchTo = '';
switch ($handling) {
case self::SSLHANDLING_REQUIRE_HTTP:
if (self::isHTTPSRequest()) {
$switchTo = 'http';
}
break;
case self::SSLHANDLING_REQUIRE_HTTPS:
if (!self::isHTTPSRequest()) {
$switchTo = 'https';
}
}
if (!strlen($switchTo)) {
return;
}
if (!$config['akRedirectEditors']) {
$user = User::isLoggedIn() ? new User() : null;
if (is_object($user) && $user->getUserID()) {
if (is_a($page, 'Collection')) {
$page = Page::getByID($page->getCollectionID());
}
$pp = new Permissions($page);
if (!$pp->isError()) {
if ($pp->canEditPageContents() || $pp->canEditPageProperties()) {
return;
}
}
}
}
$finalURL = '';
if ($config['akCustomDomains']) {
switch ($switchTo) {
case 'http':
$finalURL = $config['akHTTPDomain'];
break;
case 'https':
$finalURL = $config['akHTTPSDomain'];
break;
//.........这里部分代码省略.........