Exemplo n.º 1
0
 /**
  * Views the composer edit page.
  * @param string|int $ctID The collection type
  * @param string|int $cPublishParentID The parent page under which to publish
  */
 public function view($ctID = false, $cPublishParentID = false)
 {
     // Load Page objects from their IDs
     $ct = $this->setCollectionType($ctID);
     $cPublishParent = Page::getByID($cPublishParent);
     // If we couldn't load a collection type, send them to the composer menu
     if (!is_object($ct)) {
         $ctArray = CollectionType::getComposerPageTypes();
         // If there's only one collection type, just choose that one
         if (count($ctArray) === 1) {
             $ct = $ctArray[0];
             $this->redirect('/dashboard/composer/write', $ct->getCollectionTypeID());
             exit;
         }
         // Otherwise, they need to choose the CT from this array of types
         $this->set('ctArray', $ctArray);
     } else {
         // CT was set, so create a draft of this type
         $entry = ComposerPage::createDraft($ct);
         if (is_object($entry)) {
             // Check if we have a parent specified to create this draft under
             if ($cPublishParentID && is_object($cPublishParent)) {
                 // Make this draft under the specified parent
                 $entry->setComposerDraftPublishParentID($cPublishParentID);
             }
             // New draft is created, so start editing it
             $this->redirect('/dashboard/composer/write', 'edit', $entry->getCollectionID());
         } else {
             // Something failed when trying to create a draft, so send back to drafts folder
             $this->redirect('/dashboard/composer/drafts');
         }
     }
 }
Exemplo n.º 2
0
 public function activate_files($ptID)
 {
     try {
         Loader::model("collection_types");
         $pt = PageTheme::getByID($ptID);
         $txt = Loader::helper('text');
         if (!is_array($this->post('pageTypes'))) {
             throw new Exception(t("You must specify at least one template to make into a page type."));
         }
         $pkg = false;
         $pkgHandle = $pt->getPackageHandle();
         if ($pkgHandle) {
             $pkg = Package::getByHandle($pkgHandle);
         }
         foreach ($this->post('pageTypes') as $ptHandle) {
             $data['ctName'] = $txt->unhandle($ptHandle);
             $data['ctHandle'] = $ptHandle;
             $ct = CollectionType::add($data, $pkg);
         }
         $this->set('message', t('Files in the theme were activated successfully.'));
     } catch (Exception $e) {
         $this->set('error', $e);
     }
     $this->view($ptID);
 }
Exemplo n.º 3
0
 public function do_add()
 {
     $ctName = $_POST['ctName'];
     $ctHandle = $_POST['ctHandle'];
     $error = array();
     if (!$ctHandle) {
         $this->error->add(t("Handle required."));
     }
     if (!$ctName) {
         $this->error->add(t("Name required."));
     }
     $valt = Loader::helper('validation/token');
     if (!$valt->validate('add_page_type')) {
         $this->error->add($valt->getErrorMessage());
     }
     $akIDArray = $_POST['akID'];
     if (!is_array($akIDArray)) {
         $akIDArray = array();
     }
     if (!$this->error->has()) {
         try {
             if ($_POST['task'] == 'add') {
                 $nCT = CollectionType::add($_POST);
                 $this->redirect('/dashboard/pages/types', 'page_type_added');
             }
             exit;
         } catch (Exception $e1) {
             $this->error->add($e1->getMessage());
         }
     }
 }
Exemplo n.º 4
0
	public static function addStack($stackName, $type = self::ST_TYPE_USER_ADDED) {
		$ct = new CollectionType();
		$data = array();

		$parent = Page::getByPath(STACKS_PAGE_PATH);
		$data = array();
		$data['name'] = $stackName;
		if (!$stackName) {
			$data['name'] = t('No Name');
		}
		$pagetype = CollectionType::getByHandle(STACKS_PAGE_TYPE);
		$page = $parent->add($pagetype, $data);	

		// we have to do this because we need the area to exist before we try and add something to it.
		$a = Area::getOrCreate($page, STACKS_AREA_NAME);
		
		// finally we add the row to the stacks table
		$db = Loader::db();
		$stackCID = $page->getCollectionID();
		$v = array($stackName, $stackCID, $type);
		$db->Execute('insert into Stacks (stName, cID, stType) values (?, ?, ?)', $v);
		
		//Return the new stack
		return self::getByID($stackCID);
	}
Exemplo n.º 5
0
 public function save()
 {
     $this->verify($this->post('ctID'));
     if ($this->post('ctIncludeInComposer')) {
         switch ($this->post('ctComposerPublishPageMethod')) {
             case 'PARENT':
                 $page = Page::getByID($this->post('ctComposerPublishPageParentID'));
                 if ($page->isError()) {
                     $this->error->add(t('Parent page not selected'));
                 } else {
                     $this->ct->saveComposerPublishTargetPage($page);
                 }
                 break;
             case 'PAGE_TYPE':
                 $ct = CollectionType::getByID($this->post('ctComposerPublishPageTypeID'));
                 $this->ct->saveComposerPublishTargetPageType($ct);
                 break;
             default:
                 $this->ct->saveComposerPublishTargetAll();
                 break;
         }
         if (!$this->error->has()) {
             $this->ct->saveComposerAttributeKeys($this->post('composerAKID'));
             $this->redirect('/dashboard/pages/types/composer', 'view', $this->ct->getCollectionTypeID(), 'updated');
         } else {
             $this->view($this->ct->getCollectionTypeID());
         }
     } else {
         $this->ct->resetComposerData();
         $this->redirect("/dashboard/pages/types", "clear_composer");
     }
 }
Exemplo n.º 6
0
 public function createPage()
 {
     Loader::model('page');
     $parent = Page::getByID($this->location);
     $ct = CollectionType::getByID($this->ctID);
     $data = array('cName' => $this->post->title, 'cHandle' => $this->post->page_title, 'cDescription' => $this->post->description, 'cDatePublic' => $this->post->pubDate);
     $p = $parent->add($ct, $data);
     return $p;
 }
Exemplo n.º 7
0
	/** 
	 * Checks to see if the page in question is a valid composer draft for the logged in user
	 */
	protected static function isValidComposerPage($entry) {
		$ct = CollectionType::getByID($entry->getCollectionTypeID());
		if (!$ct->isCollectionTypeIncludedInComposer()) {
			return false;
		}
		$cp = new Permissions($entry);
		if (!$cp->canEditPageContents()) {
			return false;
		}			
		return true;
	}
Exemplo n.º 8
0
 public function testPageOperations()
 {
     Loader::model('page');
     Loader::model('collection_types');
     $ct = CollectionType::getByHandle('left_sidebar');
     //everything's got a default..
     $this->assertInstanceOf('CollectionType', $ct);
     //kind of weird to check this but hey
     $home = Page::getByID(HOME_CID);
     $pageName = "My Cool Page";
     $pageHandle = 'page';
     //this tests that page handles will be set as the page handle.
     //The actual add function does some transforms on the handles if they are not
     //set.
     $badPage = Page::getByID(42069);
     try {
         $page = $badPage->add($ct, array('uID' => 1, 'cName' => $pageName, 'cHandle' => $pageHandle));
     } catch (Exception $e) {
         $caught = true;
     }
     if (!$caught) {
         $this->fail('Added a page to a non-page');
     }
     $page = self::createPage($pageName, $pageHandle);
     $parentID = $page->getCollectionParentID();
     $this->assertInstanceOf('Page', $page);
     $this->assertEquals($parentID, HOME_CID);
     $this->assertSame($pageName, $page->getCollectionName());
     $this->assertSame($pageHandle, $page->getCollectionHandle());
     $this->assertSame('/' . $pageHandle, $page->getCollectionPath());
     //now we know adding pages works.
     $destination = self::createPage("Destination");
     $parentCID = $destination->getCollectionID();
     $page->move($destination);
     $parentPath = $destination->getCollectionPath();
     $handle = $page->getCollectionHandle();
     $path = $page->getCollectionPath();
     $this->assertSame($parentPath . '/' . $handle, $path);
     $this->assertSame($parentCID, $page->getCollectionParentID());
     //now we know that moving pages works
     $page->moveToTrash();
     $this->assertTrue($page->isInTrash());
     //stuff is going to the trash
     $cID = $page->getCollectionID();
     $page->delete();
     $noPage = Page::getByID($cID);
     $this->assertEquals(COLLECTION_NOT_FOUND, $noPage->error);
     //maybe there is a more certain way to determine this.
     //now we know deleting pages works
     $destination->delete();
     //clean up the destination page
 }
Exemplo n.º 9
0
 public function run()
 {
     BlockType::installBlockType('tags');
     BlockType::installBlockType('next_previous');
     BlockType::installBlockType('date_nav');
     Loader::model('collection_types');
     $blogEntry = CollectionType::getByHandle('blog_entry');
     if (!$blogEntry || !intval($blogEntry->getCollectionTypeID())) {
         $data['ctHandle'] = 'blog_entry';
         $data['ctName'] = t('Blog Entry');
         $blogEntry = CollectionType::add($data);
     }
 }
Exemplo n.º 10
0
 public function install()
 {
     Loader::model('collection_types');
     $pkg = parent::install();
     PageTheme::add('casual', $pkg);
     $pagetypearray = array(array("left_sidebar", "Left Sidebar"), array("right_sidebar", "Right Sidebar"), array("full", "One Column"), array("three_column", "Three Column Layout"));
     foreach ($pagetypearray as $value) {
         $pageType = CollectionType::getByHandle($value[0]);
         if (!$pageType) {
             $pkg = Package::getByHandle('casual');
             $newPageType = CollectionType::add(array('ctHandle' => $value[0], 'ctName' => t($value[1])), $pkg);
         } else {
             $newPageType = $pageType;
         }
     }
 }
Exemplo n.º 11
0
	public function delete($ctID, $token = '') {
		$db = Loader::db();
		$valt = Loader::helper('validation/token');
		if (!$valt->validate('delete_page_type', $token)) {
			$this->set('message', $valt->getErrorMessage());
		} else {
			// check to make sure we 
			$pageCount = $db->getOne("SELECT COUNT(*) FROM Pages WHERE cIsTemplate = 0 and ctID = ?",array($ctID));
				
			if($pageCount == 0) {
				$ct = CollectionType::getByID($ctID);
				$ct->delete();
				$this->redirect("/dashboard/pages/types");
			} else {
				$this->set("error", array(t("You must delete all pages of this type before deleting this page type.")));
			}
		}
	}
Exemplo n.º 12
0
 /**
  * Find the latest unstarted walk, so you don't need to make a new one.
  * @param $u The user for whom you're finding their walk
  * @return Collection
  */
 protected function getUnstartedWalk(User $u, Page $city)
 {
     // Find all walks for this user, in this city, with no name
     $pl = new PageList();
     $pl->filterByCollectionTypeHandle('walk');
     $pl->filterByUserID($u->getUserID());
     $pl->filterByParentID($city->getCollectionID());
     $pl->displayUnapprovedPages();
     $pl->filterByName('', true);
     $pl->filterByAttribute('exclude_page_list', true);
     // Arbitrarily use the first; it's blank anyway.
     $walk = $pl->get(1)[0];
     // If you couldn't find a walk, make a new one in the city
     if (!$walk) {
         $walk = $city->add(CollectionType::getByHandle('walk'), []);
         $walk->setAttribute('exclude_page_list', true);
     }
     return $walk;
 }
Exemplo n.º 13
0
 public function do_add()
 {
     $ctName = $_POST['ctName'];
     $ctHandle = $_POST['ctHandle'];
     $vs = Loader::helper('validation/strings');
     $error = array();
     if (!$ctHandle) {
         $this->error->add(t("Handle required."));
     } else {
         if (!$vs->handle($ctHandle)) {
             $this->error->add(t('Handles must contain only letters, numbers or the underscore symbol.'));
         }
     }
     if (CollectionType::getByHandle($ctHandle)) {
         $this->error->add(t('Handle already exists.'));
     }
     if (!$ctName) {
         $this->error->add(t("Name required."));
     } else {
         if (preg_match('/[<>{};?"`]/i', $ctName)) {
             $this->error->add(t('Invalid characters in page type name.'));
         }
     }
     $valt = Loader::helper('validation/token');
     if (!$valt->validate('add_page_type')) {
         $this->error->add($valt->getErrorMessage());
     }
     $akIDArray = $_POST['akID'];
     if (!is_array($akIDArray)) {
         $akIDArray = array();
     }
     if (!$this->error->has()) {
         try {
             if ($_POST['task'] == 'add') {
                 $nCT = CollectionType::add($_POST);
                 $this->redirect('/dashboard/pages/types', 'page_type_added');
             }
             exit;
         } catch (Exception $e1) {
             $this->error->add($e1->getMessage());
         }
     }
 }
Exemplo n.º 14
0
 /**
  * Gets a list of all pages of the collection type
  * specified by $ctID
  * 
  * @param int $ctID ID of collection type
  */
 public function show($ctID)
 {
     $hh = Loader::helper('html');
     $th = Loader::helper('text');
     $emptyList = false;
     $this->view(false);
     Loader::model('page_list');
     $pl = new PageList();
     $pl->filterByCollectionTypeID($ctID);
     if (array_key_exists('cvName', $_REQUEST)) {
         $cvName = $th->sanitize($_REQUEST['cvName']);
         $this->set('cvName', $cvName);
         $pl->filterByName($cvName);
         if (count($pl->getPage()) <= 0) {
             $pl = new PageList();
             $emptyList = true;
         }
     }
     if (!$emptyList) {
         $pl->addtoQuery('left join Pages parent ON(p1.cParentID = parent.cID)');
         $pl->sortByMultiple('parent.cDisplayOrder asc', 'p1.cDisplayOrder asc');
         $pages = $pl->getPage();
     } else {
         $pages = '';
         $this->set('emptyList', t('No entries found'));
     }
     $ct = CollectionType::getByID($ctID);
     // add all necessary header items like JavaScript and CSS files
     if (!array_key_exists('cvName', $_REQUEST) || $cvName == '') {
         $this->addHeaderItem($hh->css('composer.sort.css', 'remo_composer_list'));
         $this->addHeaderItem($hh->javascript('composer.sort.js', 'remo_composer_list'));
     }
     $this->addHeaderItem($hh->javascript('composer.overview.js', 'remo_composer_list'));
     // add variables used by view
     $this->set('customColumns', $this->loadCustomColumns($ctID));
     $this->set('ctID', $ctID);
     $this->set('ctPublishMethod', $ct->getCollectionTypeComposerPublishMethod());
     $this->set('pages', $pages);
     $this->set('displaySearchBox', $this->displaySearchBox());
     $this->set('composerListTitel', $ct->getCollectionTypeName());
     $this->set('pagesPagination', $pl->displayPaging(false, true));
 }
Exemplo n.º 15
0
 private function add_personal_homepage($user_name, $nick_name, $doc_lang)
 {
     $page = Page::getByPath("/{$doc_lang}/engineer/{$user_name}");
     if ($page->getCollectionID() > 0) {
         $this->set('error', t('Existed username: %s!', $user_name));
         return false;
     }
     $page_type = CollectionType::getByHandle('personal_homepage');
     $parent_page = Page::getByPath("/{$doc_lang}/engineer");
     $page = $parent_page->add($page_type, array('cName' => $nick_name, 'cHandle' => $user_name));
     if ($page instanceof Page) {
         $block_type = BlockType::getByHandle("fse_public_profile");
         $area = new Area('Side Bar');
         $page->addBlock($block_type, $area, array("fseUsername" => $user_name));
     } else {
         $this->set('error', t('Failed to create personal homepage!'));
         return false;
     }
     return true;
 }
Exemplo n.º 16
0
 public function update()
 {
     $valt = Loader::helper('validation/token');
     $ct = CollectionType::getByID($_REQUEST['ctID']);
     $ctName = $_POST['ctName'];
     $ctHandle = $_POST['ctHandle'];
     $vs = Loader::helper('validation/strings');
     if (!$ctHandle) {
         $this->error->add(t("Handle required."));
     } else {
         if (!$vs->handle($ctHandle)) {
             $this->error->add(t('Handles must contain only letters, numbers or the underscore symbol.'));
         }
     }
     if (!$ctName) {
         $this->error->add(t("Name required."));
     } else {
         if (preg_match('/[<>;{}?"`]/i', $ctName)) {
             $this->error->add(t('Invalid characters in page type name.'));
         }
     }
     if (!$valt->validate('update_page_type')) {
         $this->error->add($valt->getErrorMessage());
     }
     if (!$this->error->has()) {
         try {
             if (is_object($ct)) {
                 $ct->update($_POST);
                 $this->redirect('/dashboard/pages/types', 'page_type_updated');
             }
         } catch (Exception $e1) {
             $this->error->add($e1->getMessage());
         }
     }
     $this->view();
 }
Exemplo n.º 17
0
 public function swapContent($options)
 {
     if ($this->validateClearSiteContents($options)) {
         Loader::model("page_list");
         Loader::model("file_list");
         Loader::model("stack/list");
         $pl = new PageList();
         $pages = $pl->get();
         foreach ($pages as $c) {
             $c->delete();
         }
         $fl = new FileList();
         $files = $fl->get();
         foreach ($files as $f) {
             $f->delete();
         }
         // clear stacks
         $sl = new StackList();
         foreach ($sl->get() as $c) {
             $c->delete();
         }
         $home = Page::getByID(HOME_CID);
         $blocks = $home->getBlocks();
         foreach ($blocks as $b) {
             $b->deleteBlock();
         }
         $pageTypes = CollectionType::getList();
         foreach ($pageTypes as $ct) {
             $ct->delete();
         }
         // now we add in any files that this package has
         if (is_dir($this->getPackagePath() . '/content_files')) {
             Loader::library('file/importer');
             $fh = new FileImporter();
             $contents = Loader::helper('file')->getDirectoryContents($this->getPackagePath() . '/content_files');
             foreach ($contents as $filename) {
                 $f = $fh->import($this->getPackagePath() . '/content_files/' . $filename, $filename);
             }
         }
         // now we parse the content.xml if it exists.
         Loader::library('content/importer');
         $ci = new ContentImporter();
         $ci->importContentFile($this->getPackagePath() . '/content.xml');
     }
 }
Exemplo n.º 18
0
?>
		<div class="controls">
			<?php 
echo $form->text('cvName', $searchRequest['cvName'], array('style' => 'width: 120px'));
?>
		</div>
		</div>

		<div class="span3">
		<?php 
echo $form->label('ctID', t('Page Type'));
?>
		<div class="controls">
			<? 
			Loader::model('collection_types');
			$ctl = CollectionType::getList();
			$ctypes = array('' => t('** All'));
			foreach($ctl as $ct) {
				$ctypes[$ct->getCollectionTypeID()] = $ct->getCollectionTypeName();
			}
			
			print $form->select('ctID', $ctypes, $searchRequest['ctID'], array('style' => 'width:120px'))?>

		</div>
		</div>

		<div class="span3">
		<?php 
echo $form->label('numResults', t('# Per Page'));
?>
		<div class="controls">
Exemplo n.º 19
0
<?php  defined('C5_EXECUTE') or die("Access Denied."); ?> 
<?php  $c = Page::getCurrentPage(); ?>
<ul id="ccm-pagelist-tabs" class="ccm-dialog-tabs">
	<li class="ccm-nav-active"><a id="ccm-pagelist-tab-add" href="javascript:void(0);"><?php echo ($bID>0)? t('Edit') : t('Add') ?></a></li>
	<li class=""><a id="ccm-pagelist-tab-preview"  href="javascript:void(0);"><?php echo t('Preview')?></a></li>
</ul>

<input type="hidden" name="pageListToolsDir" value="<?php echo $uh->getBlockTypeToolsURL($bt)?>/" />
<div id="ccm-pagelistPane-add" class="ccm-pagelistPane">
	<div class="ccm-block-field-group">
	  <h2><?php echo t('Number and Type of Pages')?></h2>
	  <?php echo t('Display')?>
	  <input type="text" name="num" value="<?php echo $num?>" style="width: 30px">
	  <?php echo t('pages of type')?>
	  <?php 
			$ctArray = CollectionType::getList();
	
			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 
<?php

defined('C5_EXECUTE') or die("Access Denied.");
global $c;
// grab all the collections belong to the collection type that we're looking at
Loader::model('collection_types');
$ctID = $c->getCollectionTypeID();
$ct = CollectionType::getByID($ctID);
$cList = $ct->getPages();
?>
<div class="ccm-ui">
<form method="post" id="ccmBlockMasterCollectionForm" action="<?php 
echo $b->getBlockMasterCollectionAliasAction();
?>
">

	<?php 
if (count($cList) == 0) {
    ?>
	
	<?php 
    echo t("There are no pages of this type added to your website. If there were, you'd be able to choose which of those pages this block appears on.");
    ?>
	
	<?php 
} else {
    ?>
	
	<p><?php 
    echo t("Choose which pages below this particular block should appear on. Any previously selected blocks may also be removed using the checkbox. Click the checkbox in the header to select/deselect all pages.");
    ?>
Exemplo n.º 21
0
	$oc = Page::getByID($_REQUEST['origCID']);
}
if (isset($_REQUEST['destCID'] ) && is_numeric($_REQUEST['destCID'])) {
	$dc = Page::getByID($_REQUEST['destCID']);
}

$valt = Loader::helper('validation/token');

$json = array();
$json['error'] = false;
$json['message'] = false;

if (is_object($oc) && is_object($dc)) {
	$ocp = new Permissions($oc);
	$dcp = new Permissions($dc);
	$ct = CollectionType::getByID($dc->getCollectionTypeID());
	if (!$ocp->canRead()) {
		$error = t("You cannot view the source page.");
	} else if (!$dcp->canAddSubContent($ct)) {
		$error = t("You do not have sufficient privileges to add this type of page to this destination.");
	} else if (!$oc->canMoveCopyTo($dc)) {
		$error = t("You may not move/copy/alias the chosen page to that location.");
	} else {
		$error = false;
	}
}

if (!$error) {
	if ($_REQUEST['ctask']) {
		if ($valt->validate()) {
			switch($_REQUEST['ctask']) {
Exemplo n.º 22
0
             $u = new User();
             $u->unloadCollectionEdit();
             $obj->rel = 'SITEMAP';
         } else {
             //header('Location: ' . BASE_URL . DIR_REL . '/' . DISPATCHER_FILENAME . '?cID=' . $_GET['cID'] . '&mode=edit' . $step);
             //exit;
         }
         $obj->cID = $c->getCollectionID();
         print Loader::helper('json')->encode($obj);
         exit;
     }
 } else {
     if ($_POST['add']) {
         // adding a collection to a collection
         Loader::model('collection_types');
         $ct = CollectionType::getByID($_POST['ctID']);
         if ($cp->canAddSubContent($ct)) {
             // the $c below identifies that we're adding a collection _to_ that particular collection object
             //$newCollectionID = $ct->addCollection($c);
             $dt = Loader::helper('form/date_time');
             $dh = Loader::helper('date');
             $data = $_POST;
             $data['cvIsApproved'] = 0;
             $data['cDatePublic'] = $dh->getSystemDateTime($dt->translate('cDatePublic'));
             $nc = $c->add($ct, $data);
             $nvc = $nc->getVersionToModify();
             processMetaData($nvc);
             if (is_object($nc)) {
                 if ($_POST['rel'] == 'SITEMAP') {
                     if ($cp->canApproveCollection()) {
                         $v = CollectionVersion::get($nc, "RECENT");
Exemplo n.º 23
0
 public static function add($data, $pkg = null)
 {
     $db = Loader::db();
     $pkgID = $pkg == null ? 0 : $pkg->getPackageID();
     $ctIcon = FILENAME_COLLECTION_TYPE_DEFAULT_ICON;
     if (isset($data['ctIcon'])) {
         $ctIcon = $data['ctIcon'];
     }
     $ctIsInternal = 0;
     if (isset($data['ctIsInternal']) && $data['ctIsInternal']) {
         $ctIsInternal = 1;
     }
     $v = array($data['ctHandle'], $data['ctName'], $ctIcon, $ctIsInternal, $pkgID);
     $q = "insert into PageTypes (ctHandle, ctName, ctIcon, ctIsInternal, pkgID) values (?, ?, ?, ?, ?)";
     $r = $db->prepare($q);
     $res = $db->execute($r, $v);
     if ($res) {
         $ctID = $db->Insert_ID();
         // metadata
         if (is_array($data['akID'])) {
             foreach ($data['akID'] as $ak) {
                 $v2 = array($ctID, $ak);
                 $db->query("insert into PageTypeAttributes (ctID, akID) values (?, ?)", $v2);
             }
         }
         // now that we've created the collection type, we create the master collection
         $dh = Loader::helper('date');
         $cDate = $dh->getSystemDateTime();
         $data['ctID'] = $ctID;
         $cobj = Collection::add($data);
         $cID = $cobj->getCollectionID();
         $mcName = $data['cName'] ? $data['cName'] : "MC: {$data['ctName']}";
         $mcDescription = $data['cDescription'] ? $data['cDescription'] : "Master Collection For {$data['ctName']}";
         $v2 = array($cID, 1, $pkgID);
         $q2 = "insert into Pages (cID, cIsTemplate, pkgID) values (?, ?, ?)";
         $r2 = $db->prepare($q2);
         $res2 = $db->execute($r2, $v2);
         if ($res2) {
             return CollectionType::getByID($ctID);
         }
     }
 }
Exemplo n.º 24
0
<? $form = Loader::helper('form'); ?>
<?
$attribs = array();

$allowedAKIDs = $assignment->getAttributesAllowedArray();

$requiredKeys = array();
$usedKeys = array();
if ($c->getCollectionTypeID() > 0 && !$c->isMasterCollection()) {
	$cto = CollectionType::getByID($c->getCollectionTypeID());
	$aks = $cto->getAvailableAttributeKeys();
	foreach($aks as $ak) {
		$requiredKeys[] = $ak->getAttributeKeyID();
	}
}
$setAttribs = $c->getSetCollectionAttributes();
foreach($setAttribs as $ak) {
	$usedKeys[] = $ak->getAttributeKeyID();
}
$usedKeysCombined = array_merge($requiredKeys, $usedKeys);

?>

<div class="row">
<div id="ccm-attributes-column" class="span3">
	<h6><?php 
echo t("All Attributes");
?>
</h6>
	<div class="ccm-block-type-search-wrapper ">
 /** 
  * Gets the path to a particular page type controller
  */
 public function pageTypeControllerPath($ctHandle)
 {
     self::model('collection_types');
     $ct = CollectionType::getByHandle($ctHandle);
     if (!is_object($ct)) {
         return false;
     }
     $pkgHandle = $ct->getPackageHandle();
     $env = Environment::get();
     $path = $env->getPath(DIRNAME_CONTROLLERS . '/' . DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php', $pkgHandle);
     if (file_exists($path)) {
         return $path;
     }
 }
Exemplo n.º 26
0
$valt = Loader::helper('validation/token');
$valc = Loader::helper('concrete/validation');
$form = Loader::helper('form');
$ctArray = CollectionType::getList();
$args['section'] = 'collection_types';
$u = new User();
Loader::model('file_set');
$pageTypeIconsFS = FileSet::getByName("Page Type Icons");
$cID = Loader::helper('security')->sanitizeInt($_GET['cID']);
if ($cID && $_GET['task'] == 'load_master') {
    $u->loadMasterCollectionEdit($cID, 1);
    header('Location: ' . BASE_URL . DIR_REL . '/' . DISPATCHER_FILENAME . '?cID=' . $cID . '&mode=edit');
    exit;
}
if ($_REQUEST['task'] == 'edit') {
    $ct = CollectionType::getByID($_REQUEST['ctID']);
    if (is_object($ct)) {
        $ctName = $ct->getCollectionTypeName();
        $ctHandle = $ct->getCollectionTypeHandle();
        $ctName = Loader::helper("text")->entities($ctName);
        $ctHandle = Loader::helper('text')->entities($ctHandle);
        $ctEditMode = true;
    }
}
?>

<?php 
if ($ctEditMode) {
    $ct->populateAvailableAttributeKeys();
    $akIDArray = $_POST['akID'];
    if (!is_array($akIDArray)) {
Exemplo n.º 27
0
	public function getFilesInTheme() {
		Loader::model('collection_types');
		Loader::model('single_page');
		
		$dh = Loader::helper('file');
		$ctlist = CollectionType::getList();
		$cts = array();
		foreach($ctlist as $ct) {
			$cts[] = $ct->getCollectionTypeHandle();
		}
		
		$filesTmp = $dh->getDirectoryContents($this->ptDirectory);
		foreach($filesTmp as $f) {
			if (strrchr($f, '.') == PageTheme::THEME_EXTENSION) {
				$fHandle = substr($f, 0, strpos($f, '.'));
				
				if ($f == FILENAME_THEMES_VIEW) {
					$type = PageThemeFile::TFTYPE_VIEW;
				} else if ($f == FILENAME_THEMES_DEFAULT) {
					$type = PageThemeFile::TFTYPE_DEFAULT;
				} else if (in_array($f, SinglePage::getThemeableCorePages())) {
					$type = PageThemeFile::TFTYPE_SINGLE_PAGE;
				} else if (in_array($fHandle, $cts)) {
					$type = PageThemeFile::TFTYPE_PAGE_TYPE_EXISTING;
				} else {
					$type = PageThemeFile::TFTYPE_PAGE_TYPE_NEW;
				}
				
				$pf = new PageThemeFile();
				$pf->setFilename($f);
				$pf->setType($type);
				$files[] = $pf;
			}
		}
		
		return $files;
	}
Exemplo n.º 28
0
 function getNode($cItem, $level = 0, $autoOpenNodes = true)
 {
     if (!is_object($cItem)) {
         $cID = $cItem;
         $c = Page::getByID($cID, 'RECENT');
     } else {
         $cID = $cItem->getCollectionID();
         $c = $cItem;
     }
     $cp = new Permissions($c);
     $canEditPageProperties = $cp->canEditPageProperties();
     $canEditPageSpeedSettings = $cp->canEditPageSpeedSettings();
     $canEditPagePermissions = $cp->canEditPagePermissions();
     $canEditPageDesign = $cp->canEditPageTheme() || $cp->canEditPageType();
     $canViewPageVersions = $cp->canViewPageVersions();
     $canDeletePage = $cp->canDeletePage();
     $canAddSubpages = $cp->canAddSubpage();
     $canAddExternalLinks = $cp->canAddExternalLink();
     $nodeOpen = false;
     if (is_array($_SESSION['dsbSitemapNodes'])) {
         if (in_array($cID, $_SESSION['dsbSitemapNodes'])) {
             $nodeOpen = true;
         }
     }
     $status = '';
     $cls = $c->getNumChildren() > 0 ? "folder" : "file";
     $leaf = $c->getNumChildren() > 0 ? false : true;
     $numSubpages = $c->getNumChildren() > 0 ? $c->getNumChildren() : '';
     $cvName = $c->getCollectionName() ? $c->getCollectionName() : '(No Title)';
     $cvName = $c->isSystemPage() ? t($cvName) : $cvName;
     $selected = ConcreteDashboardSitemapHelper::isOneTimeActiveNode($cID) ? true : false;
     $ct = CollectionType::getByID($c->getCollectionTypeID());
     $isInTrash = $c->isInTrash();
     $canCompose = false;
     if (is_object($ct)) {
         if ($ct->isCollectionTypeIncludedInComposer()) {
             $h = Loader::helper('concrete/dashboard');
             if ($cp->canEditPageProperties() && $h->canAccessComposer()) {
                 $canCompose = true;
             }
         }
     }
     $isTrash = $c->getCollectionPath() == TRASH_PAGE_PATH;
     if ($isTrash || $isInTrash) {
         $pk = PermissionKey::getByHandle('empty_trash');
         if (!$pk->validate()) {
             return false;
         }
     }
     $cIcon = $c->getCollectionIcon();
     $cAlias = $c->isAlias();
     $cPointerID = $c->getCollectionPointerID();
     if ($cAlias) {
         if ($cPointerID > 0) {
             $cIcon = ASSETS_URL_IMAGES . '/icons/alias.png';
             $cAlias = 'POINTER';
             $cID = $c->getCollectionPointerOriginalID();
         } else {
             $cIcon = ASSETS_URL_IMAGES . '/icons/alias_external.png';
             $cAlias = 'LINK';
         }
     }
     $node = array('cvName' => $cvName, 'cIcon' => $cIcon, 'cAlias' => $cAlias, 'isInTrash' => $isInTrash, 'isTrash' => $isTrash, 'numSubpages' => $numSubpages, 'status' => $status, 'canEditPageProperties' => $canEditPageProperties, 'canEditPageSpeedSettings' => $canEditPageSpeedSettings, 'canEditPagePermissions' => $canEditPagePermissions, 'canEditPageDesign' => $canEditPageDesign, 'canViewPageVersions' => $canViewPageVersions, 'canDeletePage' => $canDeletePage, 'canAddSubpages' => $canAddSubpages, 'canAddExternalLinks' => $canAddExternalLinks, 'canCompose' => $canCompose, 'id' => $cID, 'selected' => $selected);
     if ($cID == 1 || $nodeOpen && $autoOpenNodes) {
         // We open another level
         $node['subnodes'] = $this->getSubNodes($cID, $level, false, $autoOpenNodes);
     }
     return $node;
 }
Exemplo n.º 29
0
 public static function getByID($bID, $c = null, $a = null)
 {
     if ($c == null && $a == null) {
         $cID = 0;
         $arHandle = "";
         $cvID = 0;
         $b = Cache::get('block', $bID);
     } else {
         if (is_object($a)) {
             $arHandle = $a->getAreaHandle();
         } else {
             if ($a != null) {
                 $arHandle = $a;
                 $a = Area::getOrCreate($c, $a);
             }
         }
         $cID = $c->getCollectionID();
         $cvID = $c->getVersionID();
         $b = Cache::get('block', $bID . ':' . $cID . ':' . $cvID . ':' . $arHandle);
         if ($b instanceof Block) {
             return $b;
         }
     }
     if ($b instanceof Block) {
         return $b;
     }
     $db = Loader::db();
     $b = new Block();
     if ($c == null && $a == null) {
         // just grab really specific block stuff
         $q = "select bID, bIsActive, BlockTypes.btID, BlockTypes.btHandle, BlockTypes.pkgID, BlockTypes.btName, bName, bDateAdded, bDateModified, bFilename, Blocks.uID from Blocks inner join BlockTypes on (Blocks.btID = BlockTypes.btID) where bID = ?";
         $b->isOriginal = 1;
         $v = array($bID);
     } else {
         $b->arHandle = $arHandle;
         $b->a = $a;
         $b->cID = $cID;
         $b->c = $c ? $c : '';
         $vo = $c->getVersionObject();
         $cvID = $vo->getVersionID();
         $v = array($b->arHandle, $cID, $cvID, $bID);
         $q = "select CollectionVersionBlocks.isOriginal, BlockTypes.pkgID, CollectionVersionBlocks.cbOverrideAreaPermissions, CollectionVersionBlocks.cbDisplayOrder,\n\t\t\tBlocks.bIsActive, Blocks.bID, Blocks.btID, bName, bDateAdded, bDateModified, bFilename, btHandle, Blocks.uID from CollectionVersionBlocks inner join Blocks on (CollectionVersionBlocks.bID = Blocks.bID)\n\t\t\tinner join BlockTypes on (Blocks.btID = BlockTypes.btID) where CollectionVersionBlocks.arHandle = ? and CollectionVersionBlocks.cID = ? and (CollectionVersionBlocks.cvID = ? or CollectionVersionBlocks.cbIncludeAll=1) and CollectionVersionBlocks.bID = ?";
     }
     $r = $db->query($q, $v);
     $row = $r->fetchRow();
     if (is_array($row)) {
         $b->setPropertiesFromArray($row);
         $b->csrID = $db->GetOne('select csrID from CollectionVersionBlockStyles where cID = ? and cvID = ? and arHandle = ? and bID = ?', array($cID, $cvID, $b->arHandle, $bID));
         $r->free();
         $bt = BlockType::getByID($b->getBlockTypeID());
         $class = $bt->getBlockTypeClass();
         if ($class == false) {
             // we can't find the class file, so we return
             return false;
         }
         $b->instance = new $class($b);
         $b->populateIsGlobal();
         if ($c != null) {
             $ct = CollectionType::getByID($c->getCollectionTypeID());
             if (is_object($ct)) {
                 if ($ct->isCollectionTypeIncludedInComposer()) {
                     if ($c->isMasterCollection()) {
                         $ctID = $c->getCollectionTypeID();
                         $ccbID = $bID;
                     } else {
                         $tempBID = $b->getBlockID();
                         while ($tempBID != false && $tempBID != 0) {
                             $originalBID = $tempBID;
                             $tempBID = $db->GetOne('select distinct br.originalBID from BlockRelations br inner join CollectionVersionBlocks cvb on cvb.bID = br.bID where br.bID = ? and cvb.cID = ?', array($tempBID, $cID));
                         }
                         if ($originalBID && is_object($c)) {
                             $ctID = $c->getCollectionTypeID();
                             $ccbID = $originalBID;
                         }
                     }
                     if ($ctID && $ccbID) {
                         $cb = $db->GetRow('select bID, ccFilename from ComposerContentLayout where ctID = ? and bID = ?', array($ctID, $ccbID));
                         if (is_array($cb) && $cb['bID'] == $ccbID) {
                             $b->bIncludeInComposer = 1;
                             $b->cbFilename = $cb['ccFilename'];
                         }
                     }
                 }
             }
         }
         if ($c != null || $a != null) {
             $ca = new Cache();
             $ca->set('block', $bID . ':' . $cID . ':' . $cvID . ':' . $arHandle, $b);
         } else {
             $ca = new Cache();
             $ca->set('block', $bID, $b);
         }
         return $b;
     }
 }
Exemplo n.º 30
0
 /**
  * Adds a new page of a certain type, using a passed associate array to setup value. $data may contain any or all of the following:
  * "uID": User ID of the page's owner
  * "pkgID": Package ID the page belongs to
  * "cName": The name of the page
  * "cHandle": The handle of the page as used in the path
  * "cDatePublic": The date assigned to the page
  * @param collectiontype $ct
  * @param array $data
  * @return page
  **/
 public function add(CollectionType $ct, $data)
 {
     $db = Loader::db();
     $txt = Loader::helper('text');
     // the passed collection is the parent collection
     $cParentID = $this->getCollectionID();
     $u = new User();
     if (isset($data['uID'])) {
         $uID = $data['uID'];
     } else {
         $uID = $u->getUserID();
         $data['uID'] = $uID;
     }
     if (isset($data['pkgID'])) {
         $pkgID = $data['pkgID'];
     } else {
         if ($ct->getPackageID() > 0) {
             $pkgID = $ct->getPackageID();
         } else {
             $pkgID = 0;
         }
     }
     if (isset($data['cName'])) {
         $data['name'] = $data['cName'];
     }
     if (!$data['cHandle']) {
         // make the handle out of the title
         $handle = $txt->urlify($data['name']);
     } else {
         $handle = $txt->urlify($data['cHandle']);
     }
     $handle = str_replace('-', PAGE_PATH_SEPARATOR, $handle);
     $data['handle'] = $handle;
     $dh = Loader::helper('date');
     $cDate = $dh->getSystemDateTime();
     $cDatePublic = $data['cDatePublic'] ? $data['cDatePublic'] : null;
     $data['ctID'] = $ct->getCollectionTypeID();
     if ($ct->getCollectionTypeHandle() == STACKS_PAGE_TYPE) {
         $data['cvIsNew'] = 0;
     }
     $cobj = parent::add($data);
     $cID = $cobj->getCollectionID();
     $ctID = $ct->getCollectionTypeID();
     $masterCID = $ct->getMasterCollectionID();
     $masterCollection = Page::getByID($masterCID);
     //$this->rescanChildrenDisplayOrder();
     $cDisplayOrder = $this->getNextSubPageDisplayOrder();
     $cInheritPermissionsFromCID = $this->overrideTemplatePermissions() ? $this->getPermissionsCollectionID() : $masterCID;
     $cInheritPermissionsFrom = $this->overrideTemplatePermissions() ? "PARENT" : "TEMPLATE";
     // inherit cache settings from collection type
     $cCacheFullPageContent = $masterCollection->getCollectionFullPageCaching();
     $cCacheFullPageContentOverrideLifetime = $masterCollection->getCollectionFullPageCachingLifetime();
     $cCacheFullPageContentLifetimeCustom = $masterCollection->getCollectionFullPageCachingLifetimeCustomValue();
     $v = array($cID, $cParentID, $uID, $cInheritPermissionsFrom, $this->overrideTemplatePermissions(), $cInheritPermissionsFromCID, $cDisplayOrder, $pkgID, $cCacheFullPageContent, $cCacheFullPageContentOverrideLifetime, $cCacheFullPageContentLifetimeCustom);
     $q = "insert into Pages (cID, cParentID, uID, cInheritPermissionsFrom, cOverrideTemplatePermissions, cInheritPermissionsFromCID, cDisplayOrder, pkgID, cCacheFullPageContent, cCacheFullPageContentOverrideLifetime, cCacheFullPageContentLifetimeCustom) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
     $r = $db->prepare($q);
     $res = $db->execute($r, $v);
     $newCID = $cID;
     if ($res) {
         // Collection added with no problem -- update cChildren on parrent
         Loader::model('page_statistics');
         PageStatistics::incrementParents($newCID);
         if ($r) {
             // now that we know the insert operation was a success, we need to see if the collection type we're adding has a master collection associated with it
             if ($masterCID) {
                 $this->_associateMasterCollectionBlocks($newCID, $masterCID);
                 $this->_associateMasterCollectionAttributes($newCID, $masterCID);
             }
         }
         $pc = Page::getByID($newCID, 'RECENT');
         // run any internal event we have for page addition
         Events::fire('on_page_add', $pc);
         $pc->rescanCollectionPath();
     }
     return $pc;
 }