Created
January 22, 2015 17:41
-
-
Save jhartman86/8f2e6957f55f0b3d24dd to your computer and use it in GitHub Desktop.
Concrete5.7 package progress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Ajax data accessors | |
*/ | |
namespace Concrete\Package\Focal\Ajax { | |
defined('C5_EXECUTE') or die(_("Access Denied.")); | |
use Controller; | |
class Data extends Controller { | |
/** | |
* @todo: build out dynamic handler | |
*/ | |
public function handler(){ | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> | |
<!DOCTYPE html> | |
<html lang="<?php echo Localization::activeLanguage(); ?>" class="<?php echo Page::getCurrentPage()->isEditMode() ? 'cms-editing' : 'false'; ?>"> | |
<head> | |
<?php $this->inc('elements/head.php'); ?> | |
</head> | |
<body> | |
<div id="page-body" class="<?php echo $c->getPageWrapperClass()?>"> | |
<?php $this->inc('elements/header.php'); ?> | |
<main> | |
<?php for($i = 1; $i <= (int)$areaCount; $i++): ?> | |
<section> | |
<?php | |
/** @var $a \Concrete\Core\Area\Area */ | |
$a = new Area("Main {$i}"); | |
$a->enableGridContainer(); | |
$a->display($c); | |
?> | |
</section> | |
<?php endfor; ?> | |
</main> | |
<?php $this->inc('elements/footer.php'); ?> | |
</div> | |
<?php Loader::element('footer_required'); ?> | |
<script type="text/javascript" src="<?php echo $this->getThemePath(); ?>/js/theme.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Concrete\Package\Focal; | |
defined('C5_EXECUTE') or die(_("Access Denied.")); | |
/** @link https://github.com/concrete5/concrete5-5.7.0/blob/develop/web/concrete/config/app.php#L10-L90 Aliases */ | |
use Loader; /** @see \Concrete\Core\Legacy\Loader */ | |
use Route; /** @see \Concrete\Core\Routing\Router */ | |
use Package; /** @see \Concrete\Core\Package\Package */ | |
use PageType; /** @see \Concrete\Core\Page\Type\Type */ | |
use PageTemplate; /** @see \Concrete\Core\Page\Template */ | |
use PageTheme; /** @see \Concrete\Core\Page\Theme\Theme */ | |
use CollectionAttributeKey; /** @see \Concrete\Core\Attribute\Key\CollectionKey */ | |
use Concrete\Core\Page\Type\PublishTarget\Type\Type as PublishTargetType; | |
class Controller extends Package { | |
const COLLECTION_ATTRIBUTE_SECTIONS = 'page_sections'; | |
protected $pkgHandle = 'focal'; | |
protected $appVersionRequired = '5.7'; | |
protected $pkgVersion = '0.14'; | |
/** @return string */ | |
public function getPackageName(){ | |
return t('Focal'); | |
} | |
/** @return string */ | |
public function getPackageDescription(){ | |
return t('Focal site package'); | |
} | |
/** | |
* @link http://www.concrete5.org/community/forums/5-7-discussion/a-few-questions-about-porting-packages-and-themes-to-5.7/#654225 | |
*/ | |
public function on_start(){ | |
Route::register('/__data', '\Concrete\Package\Focal\Ajax\Data::handler'); | |
} | |
/** @return void */ | |
public function uninstall(){ | |
parent::uninstall(); | |
} | |
/** @return void */ | |
public function install(){ | |
parent::install(); | |
$this->installOrUpdate(); | |
} | |
/** @return void */ | |
public function upgrade(){ | |
parent::upgrade(); | |
$this->installOrUpdate(); | |
} | |
/** | |
* Handle both install and update tasks. Easier to keep everything | |
* in sync. | |
* @return void | |
*/ | |
protected function installOrUpdate(){ | |
$this->pkgThemes() | |
->pkgTemplates() | |
->pkgPageTypes() | |
->pkgCollectionAttributes(); | |
} | |
/** | |
* @return Controller | |
*/ | |
protected function pkgThemes(){ | |
try { | |
if( ! is_object(PageTheme::getByHandle('focalize')) ){ | |
/** @var $theme \Concrete\Core\Page\Theme\Theme */ | |
$theme = PageTheme::add('focalize', $this->packageObject()); | |
$theme->applyToSite(); | |
} | |
}catch(Exception $e){ /* All good, fail silently */ } | |
return $this; | |
} | |
/** | |
* @return Controller | |
*/ | |
protected function pkgTemplates(){ | |
if( ! PageTemplate::getByHandle('article') ){ | |
PageTemplate::add('article', t('Article'), 'full.png', $this->packageObject()); | |
} | |
return $this; | |
} | |
/** | |
* @return Controller | |
*/ | |
protected function pkgPageTypes(){ | |
// Setup Article Page Type, if not defined yet | |
if( !(PageType::getByHandle('article')) ){ | |
/** @var $ptArticle \Concrete\Core\Page\Type\Type */ | |
$ptArticle = PageType::add(array( | |
'handle' => 'article', | |
'name' => t('Article'), | |
'defaultTemplate' => PageTemplate::getByHandle('article'), | |
'ptIsFrequentlyAdded' => 1, | |
'ptLaunchInComposer' => 1 | |
), $this->packageObject()); | |
// Set configured publish target | |
$ptArticle->setConfiguredPageTypePublishTargetObject( | |
PublishTargetType::getByHandle('all')->configurePageTypePublishTarget($ptArticle, array( | |
'ptID' => $ptArticle->getPageTypeID() | |
)) | |
); | |
/** @var $layoutSet \Concrete\Core\Page\Type\Composer\FormLayoutSet */ | |
$layoutSet = $ptArticle->addPageTypeComposerFormLayoutSet('Basics', 'Basics'); | |
/** @var $controlTypeCorePageProperty \Concrete\Core\Page\Type\Composer\Control\Type\CorePagePropertyType */ | |
$controlTypeCorePageProperty = \Concrete\Core\Page\Type\Composer\Control\Type\Type::getByHandle('core_page_property'); | |
/** @var $controlTypeName \Concrete\Core\Page\Type\Composer\Control\CorePageProperty\NameCorePageProperty */ | |
$controlTypeName = $controlTypeCorePageProperty->getPageTypeComposerControlByIdentifier('name'); | |
$controlTypeName->addToPageTypeComposerFormLayoutSet($layoutSet) | |
->updateFormLayoutSetControlRequired(true); | |
/** @var $controlTypePublishTarget \Concrete\Core\Page\Type\Composer\Control\CorePageProperty\PublishTargetCorePageProperty */ | |
$controlTypePublishTarget = $controlTypeCorePageProperty->getPageTypeComposerControlByIdentifier('publish_target'); | |
$controlTypePublishTarget->addToPageTypeComposerFormLayoutSet($layoutSet) | |
->updateFormLayoutSetControlRequired(true); | |
} | |
return $this; | |
} | |
/** | |
* @return Controller | |
*/ | |
protected function pkgCollectionAttributes(){ | |
if( ! is_object(CollectionAttributeKey::getByHandle(self::COLLECTION_ATTRIBUTE_SECTIONS)) ){ | |
CollectionAttributeKey::add($this->attributeType('number'), array( | |
'akHandle' => self::COLLECTION_ATTRIBUTE_SECTIONS, | |
'akName' => 'Page Sections' | |
), $this->packageObject()); | |
} | |
return $this; | |
} | |
/** | |
* Memoize attribute types. | |
* @param string $handle | |
* @return \Concrete\Core\Attribute\Type || Null | |
*/ | |
private function attributeType( $handle ){ | |
if( is_null($this->{"at_{$handle}"}) ){ | |
$attributeType = \Concrete\Core\Attribute\Type::getByHandle($handle); | |
if( is_object($attributeType) && $attributeType->getAttributeTypeID() >= 1 ){ | |
$this->{"at_{$handle}"} = $attributeType; | |
} | |
} | |
return $this->{"at_{$handle}"}; | |
} | |
/** | |
* Memoize the package object instance. | |
* @return mixed Package | null | |
*/ | |
private function packageObject(){ | |
if( $this->_packageObj === null ){ | |
$this->_packageObj = Package::getByHandle($this->pkgHandle); | |
} | |
return $this->_packageObj; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Article page type controller | |
*/ | |
namespace Concrete\Package\Focal\Controller\PageType { | |
defined('C5_EXECUTE') or die(_("Access Denied.")); | |
//use Loader, Page, Permissions, View; | |
use Concrete\Package\Focal\Controller AS PackageController; | |
/** | |
* Class Article | |
* @package Concrete\Package\Focal\Controller\PageType | |
*/ | |
class Article extends \Concrete\Package\Focal\Libraries\Base { | |
public function on_start(){ | |
parent::on_start(); | |
} | |
public function view(){ | |
$this->set('areaCount', $this->getPageObject()->getAttribute(PackageController::COLLECTION_ATTRIBUTE_SECTIONS)); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function( gulp ){ | |
/** | |
* Return full path on the file system. | |
* @param _path | |
* @returns {string} | |
*/ | |
function _packagePath(_path){ | |
return __dirname + '/' + _path; | |
} | |
var utils = require('gulp-util'), | |
concat = require('gulp-concat'), | |
uglify = require('gulp-uglify'), | |
less = require('gulp-less'), | |
jshint = require('gulp-jshint'); | |
var sourcePaths = { | |
less: { | |
core: _packagePath('themes/focalize/css/build/_core.less') | |
//,app: _packagePath('themes/focalize/css/theme.less') | |
}, | |
js: { | |
core: [ | |
//_packagePath('bower_components/fastclick/lib/fastclick.js'), | |
// _packagePath('bower_components/angular/angular.js'), | |
// _packagePath('bower_components/angular-resource/angular-resource.js'), | |
// _packagePath('bower_components/angular-route/angular-route.js'), | |
// //_packagePath('bower_components/angular-animate/angular-animate.js'), | |
// _packagePath('bower_components/gsap/src/uncompressed/TweenMax.js'), | |
// _packagePath('bower_components/gsap/src/uncompressed/TimelineMax.js'), | |
// _packagePath('bower_components/gsap/src/uncompressed/easing/EasePack.js'), | |
// _packagePath('bower_components/gsap/src/uncompressed/plugins/CSSPlugin.js'), | |
// _packagePath('bower_components/gsap/src/uncompressed/plugins/ScrollToPlugin.js'), | |
// _packagePath('js/3rd_party/*.js') | |
], | |
app: [ | |
_packagePath('themes/focalize/js/build/**/*.js') | |
] | |
} | |
}; | |
/** | |
* Sass compilation | |
* @param _style | |
* @returns {*|pipe|pipe} | |
*/ | |
function runLess( files, _compress ){ | |
return gulp.src(files) | |
.pipe(less({ | |
compress: (_compress === true) | |
})) | |
.on('error', function( err ){ | |
utils.log(utils.colors.red(err.message)); | |
this.emit('end'); | |
}) | |
.pipe(gulp.dest(_packagePath('themes/focalize/css/'))); | |
} | |
/** | |
* Javascript builds (concat, optionally minify) | |
* @param files | |
* @param fileName | |
* @param minify | |
* @returns {*|pipe|pipe} | |
*/ | |
function runJs( files, fileName, minify ){ | |
return gulp.src(files) | |
.pipe(concat(fileName)) | |
.pipe(minify === true ? uglify() : utils.noop()) | |
.pipe(gulp.dest(_packagePath('themes/focalize/js/'))); | |
} | |
/** | |
* JS-Linter using JSHint library | |
* @param files | |
* @returns {*|pipe|pipe} | |
*/ | |
function runJsHint( files ){ | |
return gulp.src(files) | |
.pipe(jshint(_packagePath('.jshintrc'))) | |
.pipe(jshint.reporter('jshint-stylish')); | |
} | |
/** | |
* Individual tasks | |
*/ | |
gulp.task('less:core:dev', function(){ return runLess(sourcePaths.less.core); }); | |
gulp.task('less:core:prod', function(){ return runLess(sourcePaths.less.core, true); }); | |
gulp.task('jshint', function(){ return runJsHint(sourcePaths.js.app); }); | |
gulp.task('js:core:dev', function(){ return runJs(sourcePaths.js.core, 'core.js') }); | |
gulp.task('js:core:prod', function(){ return runJs(sourcePaths.js.core, 'core.js', true) }); | |
gulp.task('js:app:dev', ['jshint'], function(){ return runJs(sourcePaths.js.app, 'theme.js') }); | |
gulp.task('js:app:prod', ['jshint'], function(){ return runJs(sourcePaths.js.app, 'theme.js', true) }); | |
/** | |
* Grouped tasks (by environment target) | |
*/ | |
gulp.task('build:dev', ['less:core:dev', 'js:core:dev', 'js:app:dev'], function(){ | |
utils.log(utils.colors.bgGreen('Dev build OK')); | |
}); | |
gulp.task('build:prod', ['less:core:prod', 'js:core:prod', 'js:app:prod'], function(){ | |
utils.log(utils.colors.bgGreen('Prod build OK')); | |
}); | |
/** | |
* Watch tasks | |
*/ | |
gulp.task('watch', function(){ | |
gulp.watch(_packagePath('themes/focalize/css/build/**/*.less'), {interval:1000}, ['less:core:dev']); | |
gulp.watch(_packagePath('themes/focalize/js/build/**/*.js'), {interval:1000}, ['js:app:dev']); | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Base controller, common for the theme | |
*/ | |
namespace Concrete\Package\Focal\Libraries { | |
defined('C5_EXECUTE') or die(_("Access Denied.")); | |
/** | |
* Class Base | |
* @package Concrete\Package\Focal\Libraries | |
*/ | |
class Base extends \Concrete\Core\Page\Controller\PageController { | |
public function on_start(){ | |
$this->addHeaderItem($this->get('html')->css('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css')); | |
$this->addFooterItem($this->get('html')->javascript('http://cdnjs.cloudflare.com/ajax/libs/gsap/1.14.2/TweenMax.min.js')); | |
$this->addFooterItem($this->get('html')->javascript('http://cdnjs.cloudflare.com/ajax/libs/gsap/1.14.2/plugins/ScrollToPlugin.min.js')); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment