Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion boost/uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,19 @@

function slideshow_uninstall(&$content)
{
return TRUE;
$db = \phpws2\Database::getDB();
$db->begin();
try {
$db->buildTable('ss_show')->drop();
$db->buildTable('ss_slide')->drop();
}
catch (Exception $e) {
\phpws2\Error::log($e);
throw $e;
}
$db->commit();

$content[] = "Tables dropped";
return true;

}
17 changes: 16 additions & 1 deletion class/Controller/Show/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

use Canopy\Request;
use slideshow\Factory\NavBar;
use slideshow\Factory\ShowFactory;
use slideshow\Factory\React; // Yet to be used.

class Admin extends Base
{
Expand Down Expand Up @@ -58,7 +60,7 @@ protected function viewHtmlCommand(Request $request)
{
return 'viewHtmlCommand empty';
}

protected function deleteCommand(Request $request)
{
$this->factory->delete($this->id);
Expand All @@ -70,6 +72,19 @@ protected function putCommand(Request $request)
return true;
}

protected function getJsonView($data, \Canopy\Request $request)
{
$vars = $request->getRequestVars();
$command = '';
if (!empty($data['command'])) {
$command = $data['command'];
}
if ($command == 'getDetails' && \Current_User::allow('slideshow', 'edit')) {
$result = ShowFactory::getDetails($vars['show_id']);
}
return new \phpws2\View\JsonView($result);
}

private function createShowButton()
{
$nav = new NavBar();
Expand Down
42 changes: 42 additions & 0 deletions class/Factory/React.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
namespace slideshow\Factory;

require_once PHPWS_SOURCE_DIR . 'mod/slideshow/config/react.php';


/**
* @license http://opensource.org/licenses/lgpl-3.0.html
* @author Matthew McNaney <mcnaney at gmail dot com>
*/
class React
{

public static function view($view_name)
{
static $vendor_included = false;
if (!$vendor_included) {
$script[] = self::getScript('vendor');
$vendor_included = true;
}
$script[] = self::getScript($view_name);
$react = implode("\n", $script);
$content = <<<EOF
<div id="$view_name"></div>
$react
EOF;
return $content;
}

public static function getScript($filename)
{
$root_directory = PHPWS_SOURCE_HTTP . 'mod/slideshow/javascript/';
if (SYSTEMS_REACT_DEV) {
$path = "dev/$filename.js";
} else {
$path = "build/$filename.js";
}
$script = "<script type='text/javascript' src='{$root_directory}$path'></script>";
return $script;
}

}
30 changes: 21 additions & 9 deletions class/Factory/ShowFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* GNU General Public License for more details.
*
* @author Matthew McNaney <mcnaney at gmail dot com>
* @author Tyler Craig <craigta1 at appstate dot edu>
*
* @license http://opensource.org/licenses/lgpl-3.0.html
*/
Expand All @@ -31,7 +32,25 @@ protected function build()
}

/**
*
* Selects the details about a show from the db
*
* @param $show_id
*/
public static function getDetails($show_id) {
if (empty($show_id)) {
throw new \Exception("Invalid show id");
}

$db = \phpws2\Database::getDB();
$tbl = $db->addTable('ss_show');
$tbl->addFieldConditional('id', $show_id);
$show = $db->selectOneRow();

return $show;
}

/**
*
* @param slideshow\Resource\ShowResource $show
*/
public function createImageDirectory($show)
Expand Down Expand Up @@ -75,15 +94,8 @@ public function view($id)
{
/* @var $resource \slideshow\Resource\ShowResource */
$resource = $this->load($id);
$sectionFactory = new SectionFactory();

$vars = $resource->getStringVars();
$sections = $sectionFactory->listing($resource->id);
foreach ($sections as $sec) {
$slideFactory = new SlideFactory();
$slides = $slideFactory->listing($sec['id']);
}
$vars['sections'] = $sections;

$template = new \phpws2\Template($vars);
$template->setModuleTemplate('slideshow', 'Show/view.html');
return $template->get();
Expand Down
3 changes: 3 additions & 0 deletions config/react.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
// When production come set this to false.
define('SYSTEMS_REACT_DEV', true);
37 changes: 37 additions & 0 deletions javascript/Show/ShowCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, {Component} from 'react'
export default class ShowCard extends Component {
constructor() {
this.state = {
show: {
id: 0,
title: null,
img: null,
}
}

this.loadShow = this.loadShow.bind(this)
}

/**
* Loads the details fome the back end - see Show.php
*/
loadShow(id) {
$.getJSON('./slideshow/show/admin/getDetails', {show_id: id}).done(function (data) {
this.setState({show: data})
}.bind(this))
}

render() {
const id = this.props.id
return (
<div class="card" style="width: 18rem;">
<img class="card-img-bottom" src={this.state.show.img} >
<div class="card-body">
<h5>{this.state.show.title}</h5>
<a class="btn btn-success">View</a>
<a class="btn btn-primary">Edit</a>
</div>
</div>
)
}
}
39 changes: 39 additions & 0 deletions javascript/Show/ShowList.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React, {Component} from 'react'

export default class ShowList extends Component{
constructor() {
this.state = {
showsList: getShows()
}
this.getShows = this.getShows.bind(this)
}

getShows() {
let shows

if (this.props.shows === null || this.props.shows.length === 0) {
cards = (<div class="card"><div class="card-body">
<h5>Add a Show:</h5>
<a href="#" class="btn btn-primary">New Show</a>
</div></div>)
} else {
cards = this.props.shows.map(function (id) {
return <ShowCard id={id}\>
}.bind(this))
}

return (
<div>
{cards}
</div>
)
}

render() {
return (
<div>
{this.state.showsList}
</div>
)
}
}
22 changes: 22 additions & 0 deletions javascript/Show/ShowView.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict'
import React, {Component} from 'react'
import ShowList from './ShowList.jsx'

export default class ShowView extends Component {
constructor(props) {
this.state = {}

}
}

render() [
return (
<div>
<h2>Shows:</h2>
// TODO: ALl the current shows that are associtaed with the admin user
// will be rendered her somehow...
<ShowList shows={}/>
</div>
)
]
}
14 changes: 14 additions & 0 deletions javascript/Show/present.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'
import React from 'react'

export default class present {
constructor(props) {
this.state = {
show: new Show(),
}
}

render() {
return
}
}
Empty file added javascript/Slide/edit.jsx
Empty file.
7 changes: 7 additions & 0 deletions javascript/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'
import React from 'react'
import ReactDOM from 'react-dom'
import ShowView from 'ShowView.jsx'

ReactDOM.render(
<ShowView/>, document.getElementById('ShowList'))
5 changes: 0 additions & 5 deletions templates/Section/view.html

This file was deleted.

Loading