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'); } } }
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); }
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); } } } }
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'); } } }
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; }
/** * @access private */ public function get($akID) { return CollectionAttributeKey::getByID($akID); }
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); }
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']) {
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; }
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; }
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(); }
// 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();
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; }
/** * @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; } } if (!strlen($finalURL)) { $finalURL = $switchTo . '://' . self::getRequestDomain(); } $request = Request::get(); $finalURL = rtrim($finalURL, '/') . trim(DIR_REL, '/') . '/' . @ltrim($request->getRequestPath(), '/'); if (isset($_SERVER) && is_array($_SERVER) && array_key_exists('QUERY_STRING', $_SERVER) && is_string($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING'])) { $finalURL .= '?' . $_SERVER['QUERY_STRING']; } @ob_clean(); if (!isset($_POST) || !is_array($_POST) || empty($_POST)) { header('Location: ' . $finalURL); } else { ?> <!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=<?php echo h(APP_CHARSET); ?> "> <meta charset="<?php echo h(APP_CHARSET); ?> "> <script type="text/javascript"> window.onload = function() { var F = document.all ? document.all('form') : document.getElementById('form'); F.submit(); }; </script> </head> <body> <form id="form" method="POST" action="<?php echo h($finalURL); ?> "><?php foreach ($_POST as $key => $value) { self::writeFormPost($key, $value); } ?> </form> </body> </html><?php } die; }