コード例 #1
0
ファイル: index_search.php プロジェクト: rii-J/concrete5-de
	public function run() {
		Cache::disableCache();

		Loader::library('database_indexed_search');
		$is = new IndexedSearch();
		if ($_GET['force'] == 1) {
			Loader::model('attribute/categories/collection');
			Loader::model('attribute/categories/file');
			Loader::model('attribute/categories/user');
			$attributes = CollectionAttributeKey::getList();
			$attributes = array_merge($attributes, FileAttributeKey::getList());
			$attributes = array_merge($attributes, UserAttributeKey::getList());
			foreach($attributes as $ak) {
				$ak->updateSearchIndex();
			}

			$result = $is->reindexAll(true);
		} else {
			$result = $is->reindexAll();
		}
		if ($result->count == 0) {
			return t('Indexing complete. Index is up to date');
		} else {
			if ($result->count == $is->searchBatchSize) {
				return t('Index partially updated. %s pages indexed (maximum number.) Re-run this job to continue this process.', $result->count);
			} else {
				return t('Index updated. %s %s required reindexing.', $result->count, $result->count == 1 ? t('page') : t('pages'));
			}
		}
	}
コード例 #2
0
 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);
         }
     }
 }
コード例 #3
0
ファイル: controller.php プロジェクト: robchenski/ids
 private function _setupDashboardIcon($page, $icon)
 {
     $cak = CollectionAttributeKey::getByHandle('icon_dashboard');
     if (is_object($cak)) {
         $page->setAttribute('icon_dashboard', $icon);
     }
 }
コード例 #4
0
ファイル: index_search.php プロジェクト: ceko/concrete5-1
 public function run()
 {
     Cache::disableAll();
     $is = new IndexedSearch();
     if ($_GET['force'] == 1) {
         $attributes = \CollectionAttributeKey::getList();
         $attributes = array_merge($attributes, \FileAttributeKey::getList());
         $attributes = array_merge($attributes, \UserAttributeKey::getList());
         foreach ($attributes as $ak) {
             $ak->updateSearchIndex();
         }
         $result = $is->reindexAll(true);
     } else {
         $result = $is->reindexAll();
     }
     if ($result->count == 0) {
         return t('Indexing complete. Index is up to date');
     } else {
         if ($result->count == $is->searchBatchSize) {
             return t('Index partially updated. %s pages indexed (maximum number.) Re-run this job to continue this process.', $result->count);
         } else {
             return t('Index updated.') . ' ' . t2('%d page required reindexing.', '%d pages required reindexing.', $result->count, $result->count);
         }
     }
 }
コード例 #5
0
ファイル: attributes.php プロジェクト: nveid/concrete5
 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');
         }
     }
 }
コード例 #6
0
 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);
 }
コード例 #7
0
 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;
 }
コード例 #8
0
 /**
  *  @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));
     }
 }
コード例 #9
0
 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();
 }
コード例 #10
0
ファイル: version_530.php プロジェクト: rii-J/concrete5-de
	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 );
		}
	}
コード例 #11
0
ファイル: wp.php プロジェクト: pranastae/problog_importer
 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());
         }
     }
 }
コード例 #12
0
ファイル: process.php プロジェクト: rii-J/concrete5-de
	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);
				}
			} 
		}
	}
コード例 #13
0
 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);
 }
コード例 #14
0
 public function save($data)
 {
     //parent::save($data);
     $db = Loader::db();
     $page = Page::getCurrentPage();
     $cID = $page->getCollectionID();
     $page = Page::getByID($cID);
     $page->update(array('cName' => $_REQUEST['collectionName']));
     $collectionAttributes = CollectionAttributeKey::getList();
     foreach ($collectionAttributes as $collectionAttribute) {
         if (array_key_exists($collectionAttribute->akID, $_REQUEST['akID'])) {
             $collectionAttribute->setAttribute($page, false);
         }
     }
 }
コード例 #15
0
 /** 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;
     }
 }
コード例 #16
0
ファイル: theme.php プロジェクト: r-bansal/janeswalk-web-1
 /**
  * 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;
 }
コード例 #17
0
 public function start(Zend_Queue $q)
 {
     Loader::library('database_indexed_search');
     $this->is = new IndexedSearch();
     Loader::model('attribute/categories/collection');
     Loader::model('attribute/categories/file');
     Loader::model('attribute/categories/user');
     $attributes = CollectionAttributeKey::getList();
     $attributes = array_merge($attributes, FileAttributeKey::getList());
     $attributes = array_merge($attributes, UserAttributeKey::getList());
     foreach ($attributes as $ak) {
         $ak->updateSearchIndex();
     }
     $db = Loader::db();
     $db->Execute('truncate table PageSearchIndex');
     $r = $db->Execute('select Pages.cID from Pages left join CollectionSearchIndexAttributes csia on Pages.cID = csia.cID where (ak_exclude_search_index is null or ak_exclude_search_index = 0) and cIsActive = 1');
     while ($row = $r->FetchRow()) {
         $q->send($row['cID']);
     }
 }
コード例 #18
0
ファイル: version_533.php プロジェクト: Zyqsempai/amanet
 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();
 }
コード例 #19
0
ファイル: page_list.php プロジェクト: notzen/concrete5
	/** 
	 * Filters by "keywords" (which searches everything including filenames, title, tags, users who uploaded the file, tags)
	 */
	public function filterByKeywords($keywords, $simple = false) {
		$db = Loader::db();
		$kw = $db->quote($keywords);
		$qk = $db->quote('%' . $keywords . '%');
		Loader::model('attribute/categories/collection');		
		$keys = CollectionAttributeKey::getSearchableIndexedList();
		$attribsStr = '';
		foreach ($keys as $ak) {
			$cnt = $ak->getController();			
			$attribsStr.=' OR ' . $cnt->searchKeywords($keywords);
		}

		if ($simple || $this->indexModeSimple) { // $this->indexModeSimple is set by the IndexedPageList class
			$this->filter(false, "(psi.cName like $qk or psi.cDescription like $qk or psi.content like $qk {$attribsStr})");		
		} else {
			$this->indexedSearch = true;
			$this->indexedKeywords = $keywords;
			$this->autoSortColumns[] = 'cIndexScore';
			$this->filter(false, "((match(psi.cName, psi.cDescription, psi.content) against ({$kw})) {$attribsStr})");
		}
	}
コード例 #20
0
ファイル: attributes.php プロジェクト: VonUniGE/concrete5-1
 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');
         }
     }
 }
コード例 #21
0
 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);
 }
コード例 #22
0
ファイル: controller.php プロジェクト: vipkailiai/FCVOVA
 function getPages($query = null)
 {
     Loader::model('page_list');
     $db = Loader::db();
     $bID = $this->bID;
     if ($this->bID) {
         $q = "select num, cParentID, cThis, orderBy, ctID, displayAliases, rss from btEasyNewsList 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();
     switch ($row['orderBy']) {
         case 'public_desc':
             $pl->sortBy('cvDatePublic', 'desc');
             break;
         case 'public_asc':
             $pl->sortBy('cvDatePublic', 'asc');
             break;
         case 'display_asc':
             $pl->sortByDisplayOrder();
             break;
         case 'display_desc':
             $pl->sortByDisplayOrderDescending();
             break;
         case 'chrono_asc':
             $pl->sortByPublicDate();
             break;
         case 'alpha_asc':
             $pl->sortByName();
             break;
         case 'alpha_desc':
             $pl->sortByNameDescending();
             break;
         default:
             $pl->sortByPublicDateDescending();
             break;
     }
     $num = (int) $row['num'];
     if ($num > 0) {
         $pl->setItemsPerPage($num);
     }
     $c = Page::getCurrentPage();
     if (is_object($c)) {
         $this->cID = $c->getCollectionID();
     }
     $cParentID = $row['cThis'] ? $this->cID : $row['cParentID'];
     Loader::model('attribute/categories/collection');
     if ($this->displayFeaturedOnly == 1) {
         $cak = CollectionAttributeKey::getByHandle('is_featured');
         if (is_object($cak)) {
             $pl->filterByIsFeatured(1);
         }
     }
     if (!$row['displayAliases']) {
         $pl->filterByIsAlias(0);
     }
     $pl->filter('cvName', '', '!=');
     if ($row['ctID']) {
         $pl->filterByCollectionTypeID($row['ctID']);
     }
     $columns = $db->MetaColumns(CollectionAttributeKey::getIndexedSearchTable());
     if (isset($columns['AK_EXCLUDE_PAGE_LIST'])) {
         $pl->filter(false, '(ak_exclude_page_list = 0 or ak_exclude_page_list is null)');
     }
     if (intval($row['cParentID']) != 0) {
         $pl->filterByParentID($cParentID);
     }
     //Publish Date Filter
     $dt = Loader::helper('date');
     $pl->filter('cvDatePublic', $dt->getLocalDateTime(), '<');
     if ($num > 0) {
         $pages = $pl->getPage();
     } else {
         $pages = $pl->get();
     }
     $this->set('pl', $pl);
     return $pages;
 }
コード例 #23
0
ファイル: PageList.php プロジェクト: digideskio/concrete5
 /**
  * Filters keyword fields by keywords (including name, description, content, and attributes.
  *
  * @param $keywords
  */
 public function filterByKeywords($keywords)
 {
     $expressions = array($this->query->expr()->like('psi.cName', ':keywords'), $this->query->expr()->like('psi.cDescription', ':keywords'), $this->query->expr()->like('psi.content', ':keywords'));
     $keys = \CollectionAttributeKey::getSearchableIndexedList();
     foreach ($keys as $ak) {
         $cnt = $ak->getController();
         $expressions[] = $cnt->searchKeywords($keywords, $this->query);
     }
     $expr = $this->query->expr();
     $this->query->andWhere(call_user_func_array(array($expr, 'orX'), $expressions));
     $this->query->setParameter('keywords', '%' . $keywords . '%');
 }
コード例 #24
0
ファイル: page_list_form.php プロジェクト: rii-J/concrete5-de
			if (is_array($ctArray)) { ?>
	  <select name="ctID" id="selectCTID">
		<option value="0">** <?php  echo t('All')?> **</option>
		<?php  foreach ($ctArray as $ct) { ?>
		<option value="<?php echo $ct->getCollectionTypeID()?>" <?php  if ($ctID == $ct->getCollectionTypeID()) { ?> selected <?php  } ?>>
		<?php echo $ct->getCollectionTypeName()?>
		</option>
		<?php  } ?>
	  </select>
	  <?php  } ?>
	  
	  <h2><?php echo t('Filter')?></h2>
	  
	  <?php 
	  Loader::model('attribute/categories/collection');
	  $cadf = CollectionAttributeKey::getByHandle('is_featured');
	  ?>
	  <input <?php  if (!is_object($cadf)) { ?> disabled <?php  } ?> type="checkbox" name="displayFeaturedOnly" value="1" <?php  if ($displayFeaturedOnly == 1) { ?> checked <?php  } ?> style="vertical-align: middle" />
	  <?php echo t('Featured pages only.')?>
		<?php  if (!is_object($cadf)) { ?>
			 <?php echo t('(<strong>Note</strong>: You must create the "is_featured" page attribute first.)');?></span>
		<?php  } ?>
		<br/>
		<input type="checkbox" name="displayAliases" value="1" <?php  if ($displayAliases == 1) { ?> checked <?php  } ?> />
		<?php echo t('Display page aliases.')?>
		<br/>
		
	</div>
	<div class="ccm-block-field-group">
		<h2><?php echo t('Pagination')?></h2>
		<input type="checkbox" name="paginate" value="1" <?php  if ($paginate == 1) { ?> checked <?php  } ?> />
コード例 #25
0
ファイル: collection_types.php プロジェクト: Zyqsempai/amanet
 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;
 }
コード例 #26
0
ファイル: search.php プロジェクト: ojalehto/concrete5-legacy
 public function getRequestedSearchResults()
 {
     $dh = Loader::helper('concrete/dashboard/sitemap');
     if (!$dh->canRead()) {
         return false;
     }
     $pageList = new PageList();
     $pageList->ignoreAliases();
     $pageList->enableStickySearchRequest();
     if ($_REQUEST['submit_search']) {
         $pageList->resetSearchRequest();
     }
     $req = $pageList->getSearchRequest();
     $pageList->displayUnapprovedPages();
     $columns = PageSearchColumnSet::getCurrent();
     $this->set('columns', $columns);
     $cvName = h($req['cvName']);
     if ($cvName != '') {
         $pageList->filterByName($cvName);
     }
     if ($req['numResults'] && Loader::helper('validation/numbers')->integer($req['numResults'])) {
         $pageList->setItemsPerPage($req['numResults']);
     }
     if ($req['ctID']) {
         $pageList->filterByCollectionTypeID($req['ctID']);
     }
     if (is_array($req['selectedSearchField'])) {
         foreach ($req['selectedSearchField'] as $i => $item) {
             // due to the way the form is setup, index will always be one more than the arrays
             if ($item != '') {
                 switch ($item) {
                     case 'keywords':
                         $keywords = htmlentities($req['keywords'], ENT_QUOTES, APP_CHARSET);
                         $pageList->filterByKeywords($keywords);
                         break;
                     case 'num_children':
                         $symbol = '=';
                         if ($req['cChildrenSelect'] == 'gt') {
                             $symbol = '>';
                         } else {
                             if ($req['cChildrenSelect'] == 'lt') {
                                 $symbol = '<';
                             }
                         }
                         $pageList->filterByNumberOfChildren($req['cChildren'], $symbol);
                         break;
                     case 'owner':
                         $ui = UserInfo::getByUserName($req['owner']);
                         if (is_object($ui)) {
                             $pageList->filterByUserID($ui->getUserID());
                         } else {
                             $pageList->filterByUserID(-1);
                         }
                         break;
                     case 'theme':
                         $pageList->filter('ptID', $_REQUEST['ptID']);
                         break;
                     case 'parent':
                         if (isset($req['_cParentAll'])) {
                             $req['cParentAll'] = $req['_cParentAll'];
                         }
                         if ($req['cParentIDSearchField'] > 0) {
                             if ($req['cParentAll'] == 1) {
                                 $pc = Page::getByID($req['cParentIDSearchField']);
                                 $cPath = $pc->getCollectionPath();
                                 $pageList->filterByPath($cPath);
                             } else {
                                 $pageList->filterByParentID($req['cParentIDSearchField']);
                             }
                         }
                         break;
                     case 'version_status':
                         if (isset($req['_cvIsApproved'])) {
                             $req['cvIsApproved'] = $req['_cvIsApproved'];
                         }
                         $pageList->filterByIsApproved($req['cvIsApproved']);
                         break;
                     case 'permissions_inheritance':
                         $pageList->filter('cInheritPermissionsFrom', $req['cInheritPermissionsFrom']);
                         break;
                     case "date_public":
                         $dateFrom = $req['date_public_from'];
                         $dateTo = $req['date_public_to'];
                         if ($dateFrom != '') {
                             $dateFrom = date('Y-m-d', strtotime($dateFrom));
                             $pageList->filterByPublicDate($dateFrom, '>=');
                             $dateFrom .= ' 00:00:00';
                         }
                         if ($dateTo != '') {
                             $dateTo = date('Y-m-d', strtotime($dateTo));
                             $dateTo .= ' 23:59:59';
                             $pageList->filterByPublicDate($dateTo, '<=');
                         }
                         break;
                     case "last_modified":
                         $dateFrom = $req['last_modified_from'];
                         $dateTo = $req['last_modified_to'];
                         if ($dateFrom != '') {
                             $dateFrom = date('Y-m-d', strtotime($dateFrom));
                             $pageList->filterByDateLastModified($dateFrom, '>=');
                             $dateFrom .= ' 00:00:00';
                         }
                         if ($dateTo != '') {
                             $dateTo = date('Y-m-d', strtotime($dateTo));
                             $dateTo .= ' 23:59:59';
                             $pageList->filterByDateLastModified($dateTo, '<=');
                         }
                         break;
                     case "date_added":
                         $dateFrom = $req['date_added_from'];
                         $dateTo = $req['date_added_to'];
                         if ($dateFrom != '') {
                             $dateFrom = date('Y-m-d', strtotime($dateFrom));
                             $pageList->filterByDateAdded($dateFrom, '>=');
                             $dateFrom .= ' 00:00:00';
                         }
                         if ($dateTo != '') {
                             $dateTo = date('Y-m-d', strtotime($dateTo));
                             $dateTo .= ' 23:59:59';
                             $pageList->filterByDateAdded($dateTo, '<=');
                         }
                         break;
                     default:
                         Loader::model('attribute/categories/collection');
                         $akID = $item;
                         $fak = CollectionAttributeKey::get($akID);
                         if (!is_object($fak) || !$fak instanceof CollectionAttributeKey) {
                             break;
                         }
                         $type = $fak->getAttributeType();
                         $cnt = $type->getController();
                         $cnt->setRequestArray($req);
                         $cnt->setAttributeKey($fak);
                         $cnt->searchForm($pageList);
                         break;
                 }
             }
         }
     }
     $this->set('searchRequest', $req);
     return $pageList;
 }
コード例 #27
0
ファイル: controller.php プロジェクト: VonUniGE/concrete5-1
 protected function loadAttribute()
 {
     Loader::model('attribute/categories/collection');
     $ak = CollectionAttributeKey::getByHandle($this->attributeHandle);
     return $ak;
 }
コード例 #28
0
	'keywords' => t('Full Page Index'),
	'date_added' => t('Date Added'),
	'theme' => t('Theme'),
	'last_modified' => t('Last Modified'),
	'date_public' => t('Public Date'),
	'owner' => t('Page Owner'),
	'num_children' => t('# Children'),
	'version_status' => t('Approved Version')
);

if (!$searchDialog) {
	$searchFields['parent'] = t('Parent Page');
}

Loader::model('attribute/categories/collection');
$searchFieldAttributes = CollectionAttributeKey::getSearchableList();
foreach($searchFieldAttributes as $ak) {
	$searchFields[$ak->getAttributeKeyID()] = $ak->getAttributeKeyDisplayHandle();
}

?>

<? $form = Loader::helper('form'); ?>
	
	<div id="ccm-<?php 
echo $searchInstance;
?>
-search-field-base-elements" style="display: none">
	
		<span class="ccm-search-option"  search-field="keywords">
		<?php 
コード例 #29
0
	<?php 
        echo Loader::helper('concrete/dashboard')->getDashboardPaneFooterWrapper(false);
        ?>



<?php 
    } else {
        ?>

	<?php 
        echo Loader::helper('concrete/dashboard')->getDashboardPaneHeaderWrapper(t('Page Attributes'), false, false, false);
        ?>

	<?php 
        $attribs = CollectionAttributeKey::getList();
        Loader::element('dashboard/attributes_table', array('category' => $category, 'attribs' => $attribs, 'editURL' => '/dashboard/pages/attributes'));
        ?>

	<div class="ccm-pane-body ccm-pane-body-footer" style="margin-top: -25px">
	
	<form method="get" class="form-stacked inline-form-fix" action="<?php 
        echo $this->action('select_type');
        ?>
" id="ccm-attribute-type-form">
	<div class="clearfix">
	<?php 
        echo $form->label('atID', t('Add Attribute'));
        ?>
	<div class="input">
	
コード例 #30
0
ファイル: collection.php プロジェクト: VonUniGE/concrete5-1
 /** 
  * @access private 
  */
 public function get($akID)
 {
     return CollectionAttributeKey::getByID($akID);
 }