Exemple #1
0
 public function run()
 {
     // Since we added the origfilename column in 5.0.0b1 we need to populate it
     Loader::block('library_file');
     $bl = new LibraryFileBlockController();
     $bl->populateOriginalFilenames();
     // install the new block types made available
     BlockType::installBlockType('flash_content');
     BlockType::installBlockType('guestbook');
     BlockType::installBlockType('slideshow');
     BlockType::installBlockType('search');
     BlockType::installBlockType('google_map');
     BlockType::installBlockType('video');
     BlockType::installBlockType('rss_displayer');
     BlockType::installBlockType('youtube');
     BlockType::installBlockType('survey');
     // rename external form
     $bt = BlockType::getByHandle('custom_form');
     $db = Loader::db();
     $tables = $db->MetaTables('TABLES');
     if (isset($tables['btCustomForm']) && !isset($tables['btExternalForm'])) {
         $db->Execute("alter table btCustomForm rename btExternalForm");
     }
     if (is_object($bt)) {
         BlockType::installBlockType('external_form', $bt->getBlockTypeID());
     }
     // add new theme
     $th = PageTheme::getByHandle('greensalad');
     if (!is_object($th)) {
         PageTheme::add('greensalad');
     }
 }
 public function testSave()
 {
     $bt = BlockType::installBlockType($this->btHandle);
     $btx = BlockType::getByID(1);
     $class = $btx->getBlockTypeClass();
     $btc = new $class();
     $bID = 1;
     foreach ($this->requestData as $type => $requestData) {
         $nb = $bt->add($requestData);
         $data = $this->expectedRecordData[$type];
         $db = Loader::db();
         $r = $db->GetRow('select * from `' . $btc->getBlockTypeDatabaseTable() . '` where bID = ?', array($bID));
         foreach ($data as $key => $value) {
             $this->assertTrue($r[$key] == $value, 'Key `' . $key . '` did not equal expected value `' . $value . '` instead equalled `' . $r[$key] . '` (type `' . $type . '`)');
         }
         $bID++;
         ob_start();
         $bv = new BlockView($nb);
         $bv->render('view');
         $contents = ob_get_contents();
         ob_end_clean();
         $contents = trim($contents);
         if (isset($this->expectedOutput[$type])) {
             $this->assertTrue($this->expectedOutput[$type] == $contents, 'Output `' . $contents . '` did not equal expected output `' . $this->expectedOutput[$type] . '` (type `' . $type . '`)');
         }
     }
 }
Exemple #3
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);
     }
 }
Exemple #4
0
 public function testPageStylesBlock()
 {
     $ps = new \Concrete\Core\StyleCustomizer\Inline\StyleSet();
     $ps->setBackgroundColor('#aaa');
     $ps->save();
     $c = $this->createPage('This is my test page');
     $bt = BlockType::installBlockType('content');
     $b = $c->addBlock($bt, 'Main', array('content' => 'Sample content.'));
     $b->setCustomStyleSet($ps);
     $this->assertEquals(1, $b->getCustomStyleSetID());
     $b2 = Block::getByID(1, $c, 'Main');
     $this->assertEquals(1, $b2->getBlockID());
     $style = $b2->getCustomStyle();
     $this->assertInstanceOf('\\Concrete\\Core\\Block\\CustomStyle', $style);
     $b2->resetCustomStyle();
     $css = $style->getCSS();
     $this->assertEquals('ccm-custom-style-container ccm-custom-style-main-1', $style->getContainerClass());
     $this->assertEquals('.ccm-custom-style-container.ccm-custom-style-main-1{background-color:#aaa}', $css);
 }
Exemple #5
0
	public function install($btHandle = null) {
		$tp = new TaskPermission();
		if ($tp->canInstallPackages()) { 
			try {
				$resp = BlockType::installBlockType($btHandle);
				
				if ($resp != '') {
					$this->error->add($resp);
				} else {
					$this->set('message', t('Block Type Installed.'));
				}
			} catch(Exception $e) {
				$this->error->add($e);
				$this->set('error', $this->error);
			}
		} else {
			$this->error->add(t('You do not have permission to install custom block types or add-ons.'));
			$this->set('error', $this->error);
		}		
		$this->view();
	}
 public function installBlockTypes()
 {
     $bt = BlockType::getByHandle('core_scrapbook_display');
     if (!is_object($bt)) {
         BlockType::installBlockType('core_scrapbook_display');
     }
     $bt = BlockType::getByHandle('core_stack_display');
     if (!is_object($bt)) {
         BlockType::installBlockType('core_stack_display');
     }
     $bt = BlockType::getByHandle('dashboard_app_status');
     if (!is_object($bt)) {
         BlockType::installBlockType('dashboard_app_status');
     }
     $bt = BlockType::getByHandle('dashboard_featured_addon');
     if (!is_object($bt)) {
         BlockType::installBlockType('dashboard_featured_addon');
     }
     $bt = BlockType::getByHandle('dashboard_featured_theme');
     if (!is_object($bt)) {
         BlockType::installBlockType('dashboard_featured_theme');
     }
     $bt = BlockType::getByHandle('dashboard_site_activity');
     if (!is_object($bt)) {
         BlockType::installBlockType('dashboard_site_activity');
     }
     $bt = BlockType::getByHandle('dashboard_newsflow_latest');
     if (!is_object($bt)) {
         BlockType::installBlockType('dashboard_newsflow_latest');
     }
 }
Exemple #7
0
 public function run()
 {
     $db = Loader::db();
     $tables = $db->MetaTables('TABLES');
     if (in_array('btFormQuestions', $tables)) {
         //$db->CacheFlush();
         //$db->setDebug(true);
         $questionsWithBIDs = $db->getAll('SELECT max(bID) AS bID, btForm.questionSetId AS qSetId FROM `btForm` GROUP BY questionSetId');
         foreach ($questionsWithBIDs as $questionsWithBID) {
             $vals = array(intval($questionsWithBID['bID']), intval($questionsWithBID['qSetId']));
             $rs = $db->query('UPDATE btFormQuestions SET bID=? WHERE questionSetId=? AND bID=0', $vals);
         }
     }
     // now we populate files
     $num = $db->GetOne("select count(*) from Files");
     if ($num < 1) {
         $r = $db->Execute("select btFile.*, Blocks.bDateAdded from btFile inner join Blocks on btFile.bID = Blocks.bID");
         while ($row = $r->fetchRow()) {
             $v = array($row['bID'], 1, $row['filename'], null, '', $row['origfilename'], $row['bDateAdded']);
             $db->Execute("insert into FileVersions (fID, fvID, fvFilename, fvPrefix, fvExtension, fvTitle, fvDateAdded) values (?, ?, ?, ?, ?, ?, ?)", $v);
             $db->Execute("insert into Files (fID, fDateAdded) values (?, ?)", array($row['bID'], $row['bDateAdded']));
         }
     }
     Loader::model('single_page');
     // Rename Forms to Reports
     $p = Page::getByPath('/dashboard/mediabrowser');
     if (!$p->isError()) {
         $p->delete();
     }
     $p = Page::getByPath('/dashboard/files');
     if ($p->isError()) {
         $d2 = SinglePage::add('/dashboard/files');
         $d2a = SinglePage::add('/dashboard/files/search');
         $d2b = SinglePage::add('/dashboard/files/attributes');
         $d2c = SinglePage::add('/dashboard/files/sets');
         $d2d = SinglePage::add('/dashboard/files/access');
         $d2->update(array('cName' => t('File Manager'), 'cDescription' => t('All documents and images.')));
         $d3b = SinglePage::add('/dashboard/reports/surveys');
     }
     $p = Page::getByPath('/dashboard/scrapbook');
     if ($p->isError()) {
         $d3 = SinglePage::add('/dashboard/scrapbook');
         $d3b = SinglePage::add('/dashboard/scrapbook/user');
         $d3a = SinglePage::add('/dashboard/scrapbook/global');
         $d3->update(array('cName' => t('Scrapbook'), 'cDescription' => t('Share content across your site.')));
     }
     Loader::model('file_set');
     Loader::model('groups');
     $htbt = BlockType::getByHandle('html');
     if (!is_object($htbt)) {
         BlockType::installBlockType('html');
     }
     $g1 = Group::getByID(GUEST_GROUP_ID);
     $g2 = Group::getByID(REGISTERED_GROUP_ID);
     $g3 = Group::getByID(ADMIN_GROUP_ID);
     $fs = FileSet::getGlobal();
     $fs->setPermissions($g1, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE);
     $fs->setPermissions($g2, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE);
     $fs->setPermissions($g3, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_ALL);
     $p = Page::getByPath('/dashboard/reports/surveys');
     if ($p->isError()) {
         $p = SinglePage::add('/dashboard/reports/surveys');
     }
 }
Exemple #8
0
		/**
		 * refreshes the BlockType's database schema throws an Exception if error
		 * @return void
		 */
		public function refresh() {
			if ($this->getPackageID() > 0) {
				$pkg = Package::getByID($this->getPackageID());
				$resp = BlockType::installBlockTypeFromPackage($this->getBlockTypeHandle(), $pkg, $this->getBlockTypeID());			
				if ($resp != '') {
					throw new Exception($resp);
				}
			} else {
				$resp = BlockType::installBlockType($this->getBlockTypeHandle(), $this->getBlockTypeID());			
				if ($resp != '') {
					throw new Exception($resp);
				}
			}
		}
Exemple #9
0
        echo "{$t} newly installed. <br/>";
    }
    flush();
    ob_flush();
}
// install blocks
$bts = array('document_section', 'fse_app_key', 'fse_change_password', 'fse_delete_account', 'fse_email_settings', 'fse_login', 'fse_profile', 'fse_projects', 'fse_public_profile', 'fse_register', 'fse_request_to_reset_password', 'fse_reset_password', 'project_banner');
echo '<br/>';
echo 'Installing block types... <br/>';
foreach ($bts as $b) {
    $bt = BlockType::getByHandle($b);
    if ($bt instanceof BlockType) {
        echo "{$b} had been installed; skip installing. <br/>";
    } else {
        #BlockType::installBlockTypeFromPackage($b, $pkg);
        BlockType::installBlockType($b);
        echo "{$b} newly installed. <br/>";
    }
    flush();
    ob_flush();
}
// install page types
$page_type_handles = array(array('ctHandle' => 'home', 'ctName' => 'HOME'), array('ctHandle' => 'localized_home', 'ctName' => 'Localized Home'), array('ctHandle' => 'localized_projects', 'ctName' => 'Localized Projects'), array('ctHandle' => 'localized_engineers', 'ctName' => 'Localized Engineers'), array('ctHandle' => 'personal_homepage', 'ctName' => 'Personal Home'), array('ctHandle' => 'project_arena_homepage', 'ctName' => 'Arena Home'), array('ctHandle' => 'project_arena', 'ctName' => 'Arena'), array('ctHandle' => 'project_arena_subject', 'ctName' => 'Arena Subject'), array('ctHandle' => 'project_arena_zone', 'ctName' => 'Arena Zone'), array('ctHandle' => 'project_comm_forum_area', 'ctName' => 'Forum Area'), array('ctHandle' => 'project_comm_forum', 'ctName' => 'Forum'), array('ctHandle' => 'project_comm_homepage', 'ctName' => 'Community Home'), array('ctHandle' => 'project_comm_thread', 'ctName' => 'Forum Thread'), array('ctHandle' => 'project_contribute_default', 'ctName' => 'Default for Contribute'), array('ctHandle' => 'project_contribute_homepage', 'ctName' => 'Contribute Home'), array('ctHandle' => 'project_doc_homepage', 'ctName' => 'Document Home'), array('ctHandle' => 'project_doc_volume', 'ctName' => 'Document Volume'), array('ctHandle' => 'project_doc_part', 'ctName' => 'Documnet Part'), array('ctHandle' => 'project_doc_chapter', 'ctName' => 'Chapter'), array('ctHandle' => 'project_doc_all_blogs', 'ctName' => 'All Blogs'), array('ctHandle' => 'project_doc_fse_blogs', 'ctName' => 'Blog Zone'), array('ctHandle' => 'project_doc_blog', 'ctName' => 'Blog'), array('ctHandle' => 'project_download_default', 'ctName' => 'Default for Download'), array('ctHandle' => 'project_download_homepage', 'ctName' => 'Download Home'), array('ctHandle' => 'project_homepage', 'ctName' => 'Project Home'), array('ctHandle' => 'project_misc_homepage', 'ctName' => 'About'), array('ctHandle' => 'project_misc_faqs', 'ctName' => 'FAQs'), array('ctHandle' => 'project_misc_default', 'ctName' => 'Default for Misc'));
$nocache_pths = array('project_arena_homepage', 'project_arena', 'project_arena_subject', 'project_arena_zone', 'project_comm_forum_area', 'project_comm_forum', 'project_comm_homepage', 'project_comm_thread');
$short_cache_pths = array('localized_home', 'personal_homepage');
echo '<br/>';
echo 'Installing page types... <br/>';
foreach ($page_type_handles as $pth) {
    echo '	installing ' . $pth['ctHandle'] . ': ';
    $page_type = CollectionType::getByHandle($pth['ctHandle']);
    if ($page_type instanceof CollectionType) {
Exemple #10
0
	protected function importBlockTypes(SimpleXMLElement $sx) {
		if (isset($sx->blocktypes)) {
			foreach($sx->blocktypes->blocktype as $bt) {
				$pkg = ContentImporter::getPackageObject($bt['package']);
				if (is_object($pkg)) {
					BlockType::installBlockTypeFromPackage($bt['handle'], $pkg);
				} else {
					BlockType::installBlockType($bt['handle']);				
				}
			}
		}
	}
Exemple #11
0
 public function generate_block()
 {
     //In single_pages, do not prepend "action_" (unlike blocks)
     //All validation happened in the front-end prior to submission.
     //But just in case... re-validate a few key things (especially that we're not going to overwrite something that already exists)
     $handle = $this->post('handle');
     $name = $this->post('name');
     $name = empty($name) ? '' : strip_tags($name);
     $description = $this->post('description');
     $description = empty($description) ? '' : strip_tags($description);
     if (!is_writable(DIR_FILES_BLOCK_TYPES)) {
         die(t('Error: Blocks directory is not writeable!'));
     } else {
         if (empty($handle) || empty($name)) {
             die(t('Error: Block handle or name is missing!'));
         } else {
             if (!$this->validate_unique_handle($handle)) {
                 die(t("Error: Block Handle is already in use by another package or block type (or block files already exist in the \"blocks\" directory of your site)!"));
             }
         }
     }
     //Gather all field data
     $field_ids = $this->post('fieldIds');
     //The order of id's in this array reflects the user's chosen output order of the fields.
     $field_types = $this->post('fieldTypes');
     $field_labels = $this->post('fieldLabels');
     $field_prefixes = $this->post('fieldPrefixes');
     $field_suffixes = $this->post('fieldSuffixes');
     $field_static_html = $this->post('fieldStaticHtml');
     $fields_required = $this->post('fieldsRequired');
     $fields_textbox_maxlengths = $this->post('fieldTextboxMaxlengths');
     $field_image_links = $this->post('fieldImageLinks');
     $field_image_link_targets = $this->post('fieldImageLinkTargets');
     $field_image_show_alt_texts = $this->post('fieldImageShowAltTexts');
     $field_image_sizings = $this->post('fieldImageSizings');
     $field_image_widths = $this->post('fieldImageWidths');
     $field_image_heights = $this->post('fieldImageHeights');
     $field_url_targets = $this->post('fieldUrlTargets');
     $field_date_formats = $this->post('fieldDateFormats');
     $field_select_options = $this->post('fieldSelectOptions');
     $field_select_show_headers = $this->post('fieldSelectShowHeaders');
     $field_select_header_texts = $this->post('fieldSelectHeaderTexts');
     $field_default_contents = $this->post('fieldDefaultContents');
     //Set up the code generator
     Loader::library('block_generator', 'designer_content');
     $block = new DesignerContentBlockGenerator();
     if (defined('DESIGNER_CONTENT_FILE_CHMOD')) {
         $block->set_chmod(DESIGNER_CONTENT_FILE_CHMOD);
     }
     foreach ($field_ids as $id) {
         $type = $field_types[$id];
         if ($type == 'static') {
             $block->add_static_field($field_static_html[$id]);
         } else {
             if ($type == 'textbox') {
                 $block->add_textbox_field($field_labels[$id], $field_prefixes[$id], $field_suffixes[$id], !empty($fields_required[$id]), $fields_textbox_maxlengths[$id]);
             } else {
                 if ($type == 'textarea') {
                     $block->add_textarea_field($field_labels[$id], $field_prefixes[$id], $field_suffixes[$id], !empty($fields_required[$id]));
                 } else {
                     if ($type == 'image') {
                         $block->add_image_field($field_labels[$id], $field_prefixes[$id], $field_suffixes[$id], !empty($fields_required[$id]), $field_image_links[$id], $field_image_link_targets[$id], $field_image_show_alt_texts[$id], $field_image_sizings[$id], $field_image_widths[$id], $field_image_heights[$id]);
                     } else {
                         if ($type == 'file') {
                             $block->add_file_field($field_labels[$id], $field_prefixes[$id], $field_suffixes[$id], !empty($fields_required[$id]));
                         } else {
                             if ($type == 'link') {
                                 $block->add_link_field($field_labels[$id], $field_prefixes[$id], $field_suffixes[$id], !empty($fields_required[$id]));
                             } else {
                                 if ($type == 'url') {
                                     $block->add_url_field($field_labels[$id], $field_prefixes[$id], $field_suffixes[$id], !empty($fields_required[$id]), $field_url_targets[$id]);
                                 } else {
                                     if ($type == 'date') {
                                         $block->add_date_field($field_labels[$id], $field_prefixes[$id], $field_suffixes[$id], !empty($fields_required[$id]), $field_date_formats[$id]);
                                     } else {
                                         if ($type == 'select') {
                                             $block->add_select_field($field_labels[$id], $field_select_options[$id], !empty($fields_required[$id]), $field_select_show_headers[$id], $field_select_header_texts[$id]);
                                         } else {
                                             if ($type == 'wysiwyg') {
                                                 $block->add_wysiwyg_field($field_labels[$id], $field_prefixes[$id], $field_suffixes[$id], $field_default_contents[$id]);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     //Make+install block
     $block->generate($handle, $name, $description);
     $this->drop_existing_table($handle);
     BlockType::installBlockType($handle);
     //Redirect back to view page so browser refresh doesn't trigger a re-generation
     header('Location: ' . View::url("/dashboard/blocks/designer_content/?generated={$handle}"));
     exit;
 }