forked from AppStateESS/stories
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Still working through it. Not functional yet.
- Loading branch information
Showing
18 changed files
with
587 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (C) 2017 Matthew McNaney <[email protected]>. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
* MA 02110-1301 USA | ||
*/ | ||
|
||
namespace stories\Controller\Feature; | ||
|
||
use Canopy\Request; | ||
use stories\Factory\FeatureFactory as Factory; | ||
use stories\Factory\StoryMenu; | ||
use stories\Controller\RoleController; | ||
|
||
class Admin extends RoleController | ||
{ | ||
|
||
/** | ||
* @var \stories\Factory\FeatureFactory factory | ||
*/ | ||
protected $factory; | ||
|
||
protected function loadFactory() { | ||
$this->factory = new Factory; | ||
} | ||
|
||
protected function listHtmlCommand(Request $request) | ||
{ | ||
$this->factory->addStoryCss(); | ||
return $this->factory->scriptView('Feature', true, array('srcHttp'=>PHPWS_SOURCE_HTTP)); | ||
} | ||
|
||
protected function listJsonCommand(Request $request) | ||
{ | ||
return $this->factory->listing($request); | ||
} | ||
|
||
protected function postCommand(Request $request) | ||
{ | ||
return array('featureId'=>$this->factory->post($request)); | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2017 Matthew McNaney <[email protected]>. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
namespace stories\Factory; | ||
|
||
use stories\Resource\FeatureResource as Resource; | ||
use phpws2\Database; | ||
use phpws2\Settings; | ||
use Canopy\Request; | ||
use phpws2\Template; | ||
|
||
/** | ||
* Description of FeatureFactory | ||
* | ||
* @author Matthew McNaney <[email protected]> | ||
*/ | ||
class FeatureFactory extends BaseFactory | ||
{ | ||
|
||
public function build() | ||
{ | ||
return new Resource; | ||
} | ||
|
||
public function post(Request $request) | ||
{ | ||
$db = Database::getDB(); | ||
$feature = $this->build(); | ||
self::saveResource($feature); | ||
return $feature->id; | ||
} | ||
|
||
public function listing(Request $request) | ||
{ | ||
$db = Database::getDB(); | ||
$tbl = $db->addTable('storiesFeature'); | ||
$tbl->addOrderBy('sorting'); | ||
return $db->select(); | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2017 Matthew McNaney <[email protected]>. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
namespace stories\Resource; | ||
|
||
/** | ||
* Description of Feature | ||
* | ||
* @author Matthew McNaney <[email protected]> | ||
*/ | ||
class FeatureResource extends BaseResource | ||
{ | ||
protected $title; | ||
protected $active; | ||
protected $entries; | ||
protected $format; | ||
protected $columns; | ||
protected $sorting; | ||
|
||
protected $table = 'storiesFeature'; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
$this->title = new \phpws2\Variable\TextOnly(null, 'title'); | ||
$this->title->setLimit(255); | ||
$this->title->allowNull(true); | ||
$this->format = new \phpws2\Variable\Attribute('landscape', 'format'); | ||
$this->format->setLimit(20); | ||
$this->active = new \phpws2\Variable\BooleanVar(true, 'active'); | ||
$this->entries = new \phpws2\Variable\ArrayVar(null, 'entries'); | ||
$this->columns = new \phpws2\Variable\SmallInteger(2, 'columns'); | ||
$this->sorting = new \phpws2\Variable\SmallInteger(0, 'sorting'); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict' | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
const DisplayColumn = ({format, bsClass, entry,}) => { | ||
const _class = 'story-feature ' + format | ||
const thumbnailStyle = { | ||
backgroundImage: `url('${entry.thumbnail}')`, | ||
backgroundPosition: '50% 50%' | ||
} | ||
return ( | ||
<div className={bsClass}> | ||
<div className={_class}> | ||
<div className="story-thumbnail" style={thumbnailStyle}></div> | ||
<div className="story-content"> | ||
<div className="story-title"> | ||
<a> | ||
<h3>{entry.title}</h3> | ||
</a> | ||
</div> | ||
<div className="story-summary">{entry.strippedSummary}</div> | ||
<div className="published-date">Published {entry.publishDateRelative} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
DisplayColumn.propTypes = { | ||
bsClass: PropTypes.string, | ||
format: PropTypes.string, | ||
entry: PropTypes.object | ||
} | ||
|
||
DisplayColumn.defaultTypes = {} | ||
|
||
export default DisplayColumn |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
'use strict' | ||
import React, {Component} from 'react' | ||
import PropTypes from 'prop-types' | ||
import FeatureObj from './FeatureObj' | ||
import FeatureList from './FeatureList' | ||
import FeatureForm from './FeatureForm' | ||
import Message from '../AddOn/Message' | ||
import Waiting from '../AddOn/Waiting' | ||
|
||
/* global $ */ | ||
|
||
export default class Feature extends Component { | ||
constructor(props) { | ||
super(props) | ||
this.state = { | ||
message: null, | ||
currentFeature: null, | ||
currentKey: null, | ||
featureList: [], | ||
loading: true, | ||
} | ||
this.addRow = this.addRow.bind(this) | ||
this.closeMessage = this.closeMessage.bind(this) | ||
this.updateFeature = this.updateFeature.bind(this) | ||
this.loadCurrentFeature = this.loadCurrentFeature.bind(this) | ||
} | ||
|
||
componentDidMount() { | ||
this.load() | ||
} | ||
|
||
load() { | ||
$.ajax({ | ||
url: './stories/Feature', | ||
dataType: 'json', | ||
type: 'get', | ||
success: function (data) { | ||
const featureList = data | ||
this.setState({featureList: featureList, loading: false}) | ||
}.bind(this), | ||
error: function () { | ||
this.setState({ | ||
loading: false, | ||
message: { | ||
text: 'Error: Could not pull feature list', | ||
type: 'danger' | ||
} | ||
}) | ||
}.bind(this) | ||
}) | ||
} | ||
|
||
loadCurrentFeature(key) { | ||
const feature = this.state.featureList[key] | ||
if (feature.entries === 'null') { | ||
feature.entries = [] | ||
} | ||
|
||
if (feature.title === null) { | ||
feature.title = '' | ||
} | ||
this.setState({currentFeature: feature, currentKey: key,}) | ||
} | ||
|
||
addRow() { | ||
$.ajax({ | ||
url: './stories/Feature', | ||
dataType: 'json', | ||
type: 'post', | ||
success: function (data) { | ||
const feature = FeatureObj | ||
feature.id = data.featureId | ||
/* | ||
const featureList = this.state.featureList | ||
featureList.push(feature) | ||
*/ | ||
this.setState({currentFeature: FeatureObj, currentKey: data.featureId,}) | ||
}.bind(this), | ||
error: function () {}.bind(this), | ||
}) | ||
} | ||
|
||
updateFeature(feature) { | ||
this.setState({currentFeature: feature}) | ||
} | ||
|
||
closeMessage() { | ||
this.setState({message: null}) | ||
} | ||
|
||
message() { | ||
if (this.state.message !== null) { | ||
const {message} = this.state | ||
return <Message type={message.type} message={message.text} onClose={this.closeMessage}>{message.text}</Message> | ||
} | ||
} | ||
|
||
getListing() { | ||
if (this.state.loading === true) { | ||
return <Waiting/> | ||
} else if (this.state.currentKey !== null) { | ||
return <FeatureForm | ||
feature={this.state.currentFeature} | ||
srcHttp={this.props.srcHttp} | ||
update={this.updateFeature}/> | ||
} else { | ||
return <FeatureList | ||
list={this.state.featureList} | ||
loadCurrentFeature={this.loadCurrentFeature}/> | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
{this.message()} | ||
<button className="btn btn-primary mb-1" onClick={this.addRow}>Add feature row</button> | ||
{this.getListing()} | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
Feature.propTypes = { | ||
srcHttp: PropTypes.string | ||
} |
Oops, something went wrong.