Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
91fd82f
Beginning of rewrite
Stardog Apr 11, 2019
ea2aad9
Added: function to post slide
Stardog Apr 17, 2019
606c845
tidy
Stardog Apr 17, 2019
19cf64d
Added: function to delete a slide
Stardog Apr 17, 2019
c7a47ea
Added variables carouselId and thumbnail.
Stardog Apr 17, 2019
134024f
Added: defines for thumbnail dimensions
Stardog Apr 17, 2019
4d9cb38
Several changes to ease Grid usage
Stardog Apr 17, 2019
31c3e45
Extending listing functionality
Stardog Apr 17, 2019
792e375
Removed transparency
Stardog Apr 17, 2019
83b490a
Dropzone image clearing working.
Stardog Apr 17, 2019
b520efe
Including scss instead of css
Stardog Apr 17, 2019
0766595
Filled out data for grid and listing
Stardog Apr 17, 2019
d842919
New exception class
Stardog Apr 17, 2019
65ea332
Added UploadHandler
Stardog Apr 17, 2019
669ffa7
Small function to figure ratio of width and height
Stardog Apr 17, 2019
61f7e81
ignoring build/dev
Stardog Apr 17, 2019
77a2bf8
Ignoring nbproject
Stardog Apr 18, 2019
79495f7
Added runtime (not functioning) and removed comments
Stardog Apr 18, 2019
b286c2f
Added control to toggle front page status.
Stardog Apr 18, 2019
b2edfd4
Hiding default column on admin menu
Stardog Apr 18, 2019
32d326d
Added methods to put carousel on front page.
Stardog Apr 18, 2019
fe8e504
Added frontpage variable.
Stardog Apr 18, 2019
2e6e2db
building out view
Stardog Apr 18, 2019
f5aab72
Added front page check boxes.
Stardog Apr 18, 2019
6f2795e
slight altering of logic to make room for sorting.
Stardog Apr 18, 2019
8fe7558
navLeft added for left side of nav
Stardog Apr 18, 2019
dc37186
combined dimensions and ratio
Stardog Apr 18, 2019
d0cc523
these should not have been committed
Stardog Apr 18, 2019
a3a227d
Upped navbar version and added sortable
Stardog Apr 18, 2019
c47c096
Added control to sort slides
Stardog Apr 24, 2019
4056995
Changed exception to force require login in admin
Stardog Apr 24, 2019
2945f00
Switched out broken delete for default deleteResource call
Stardog Apr 24, 2019
8ad3653
Fixed conditional call
Stardog Apr 24, 2019
353aaa8
Removing defines file to prioritize defines.dist.php
Stardog Apr 24, 2019
0c6d2a3
Added maxWidth and maxHeight for images.
Stardog Apr 24, 2019
5390ed9
Fixed carousel admin to work like slides.
Stardog Apr 24, 2019
7480b22
Pulled out context menu
Stardog Apr 24, 2019
9fc2108
Added row sorting.
Stardog Apr 24, 2019
4747187
Added sorting class. not perfect.
Stardog Apr 24, 2019
6eb07dd
Switched out context menu
Stardog Apr 24, 2019
aecca37
Removed context menu
Stardog Apr 24, 2019
30095da
Moved grid header code to separate file.
Stardog Apr 24, 2019
da45068
Removing old scripts
Stardog Apr 25, 2019
8a451c9
Fixed listing not using carousel id.
Stardog Apr 25, 2019
353d128
Added options to the listing function
Stardog Apr 25, 2019
49963cb
Comment added about type.
Stardog Apr 25, 2019
f558065
Removed reference to stories
Stardog Apr 25, 2019
5641c10
Finished carousel home page view.
Stardog Apr 25, 2019
c29a5be
Added defines.php
Stardog Apr 25, 2019
ffe567f
Fixed carouselId inclusion
Stardog Apr 25, 2019
c4ffcb7
Altered error messages and checks.
Stardog Apr 25, 2019
464d4fc
Fixed save button not working on updates.
Stardog Apr 25, 2019
17fd514
Added href="#" Bootstrap didn't style properly without them
Stardog Apr 25, 2019
7affa01
Finished code to upload and display videos.
Stardog Apr 25, 2019
6c433f5
Removed old files.
Stardog Apr 29, 2019
76465ec
Added miniadmin and pinning abilities
Stardog Apr 29, 2019
b539d94
Updated to new version
Stardog Apr 29, 2019
e8f2ee2
New options added to listing function.
Stardog Apr 29, 2019
b6f304e
Added transition variable
Stardog Apr 29, 2019
b25e150
Added indicator controls
Stardog Apr 29, 2019
e2a6f9a
Tidy
Stardog Apr 29, 2019
85a927c
Added miniadmin script
Stardog Apr 29, 2019
0728e2a
Added transition controls
Stardog Apr 29, 2019
8e3c55e
Added title to top of page
Stardog Apr 29, 2019
f356ace
Fixed clear message functionality.
Stardog Apr 29, 2019
ff65a62
Added button icons
Stardog Apr 29, 2019
6f20524
Added fade control
Stardog Apr 29, 2019
68c63e0
Added fix for irl data to prevent relative link
Stardog Apr 29, 2019
9a0e3b9
Fixed video tags.
Stardog Apr 29, 2019
79b0d9f
Changed caption styling
Stardog Apr 29, 2019
94c49f9
Miniadmin control panel added.
Stardog Apr 29, 2019
7ba8a14
Fixing message at top of list.
Stardog Apr 29, 2019
67ed43d
Added link to current slide admin from the view.
Stardog May 7, 2019
be6d7dd
Greatly expanded update routine
Stardog May 7, 2019
222a911
Comment added
Stardog May 7, 2019
ba58dbb
Added saving of opacity.
Stardog May 7, 2019
322f4a6
Increased range of iterations to 5.
Stardog May 7, 2019
f3f16fa
Added top and bottom center positions.
Stardog May 7, 2019
679e6df
Removed img-fluid class from thumbnail indicators.
Stardog May 7, 2019
dc1b195
caption zone 0 is now pure center
Stardog May 7, 2019
24d79c4
Overlay activation clears message.
Stardog May 7, 2019
f753bd4
Added additional caption placement.
Stardog May 7, 2019
a46cddb
Default opactiy set to 50.
Stardog May 7, 2019
eca1c9f
Updated libraries
Stardog May 7, 2019
71f3942
Added opacity styles for slides.
Stardog May 7, 2019
2f8d6b1
Added slide edit link
Stardog May 7, 2019
625c8c4
Caption placement and indictator updates
Stardog May 7, 2019
ad2af0d
Restoring to provide backward compatibility.
Stardog May 7, 2019
56cc17d
Fixed empty call.
Stardog May 7, 2019
4a44872
Removed unused
Stardog May 7, 2019
6449cb1
Fixed link
Stardog May 7, 2019
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
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
/nbproject/private/
*~
/.babelrc
/assets.json
/nbproject/
/node_modules/
/conf/defines.php
/javascript/build/
/javascript/dev/
/config/defines.php
144 changes: 81 additions & 63 deletions Module.php
Original file line number Diff line number Diff line change
@@ -1,104 +1,122 @@
<?php

namespace carousel;

/**
*
* @author Matthew McNaney <mcnaneym@appstate.edu>
* @license http://opensource.org/licenses/lgpl-3.0.html
*/
class Module extends \Canopy\Module implements \Canopy\SettingDefaults

namespace carousel;

use Canopy\Request;
use Canopy\Response;
use Canopy\Server;
use Canopy\SettingDefaults;
use carousel\View\CarouselView;
use carousel\Factory\CarouselFactory;
use carousel\Controller\Controller;

if (is_file(PHPWS_SOURCE_DIR . 'mod/carousel/config/defines.php')) {
require_once PHPWS_SOURCE_DIR . 'mod/carousel/config/defines.php';
} else {
require_once PHPWS_SOURCE_DIR . 'mod/carousel/config/defines.dist.php';
}

class Module extends \Canopy\Module
{

public function __construct()
{
parent::__construct();
$this->setTitle('carousel');
$this->setProperName('Carousel for Bootstrap themes');
spl_autoload_register('\carousel\Module::autoloader', true, true);
}

public function getController(\Canopy\Request $request)
public static function autoloader($class_name)
{
$cmd = $request->shiftCommand();
if ($cmd == 'admin' && \Current_User::allow('carousel')) {
$admin = new \carousel\Controller\Admin($this);
return $admin;
static $not_found = array();

if (strpos($class_name, 'carousel') !== 0) {
return;
}

if (isset($not_found[$class_name])) {
return;
}
$class_array = explode('\\', $class_name);
array_shift($class_array);
$class_dir = implode('/', $class_array);

$class_path = PHPWS_SOURCE_DIR . 'mod/conference/class/' . $class_dir . '.php';
if (is_file($class_path)) {
require_once $class_path;
return true;
} else {
$not_found[] = $class_name;
return false;
}
}

public function runTime(\Canopy\Request $request)
public function getController(Request $request)
{
if (!$request->isVar('module')) {
$display = \carousel\SlideFactory::display();
if (!empty($display)) {
\Layout::add($display, 'carousel', 'slides');
try {
$controller = new Controller($this, $request);
return $controller;
} catch (\conference\Exception\PrivilegeMissing $e) {
if ($request->isGet() && !$request->isAjax()) {
\Current_User::requireLogin();
} else {
throw $e;
}
}
}

public function afterRun(\Canopy\Request $request, \Canopy\Response $response)
public function runTime(Request $request)
{
$key = \Canopy\Key::getCurrent();
if ($key && !$key->isDummy()) {
$this->checkKey($key->id);
if (version_compare($this->version, '2.0.0', '<')) {
return;
}
if (!$request->isVar('module')) {
$view = new CarouselView;
$factory = new CarouselFactory;
$carousel = $factory->getHomeCarousel();
if (!empty($carousel)) {
$homeView = $view->view($carousel);
\Layout::add($homeView, 'carousel', 'slides');
if (\Current_User::allow('carousel')) {
\MiniAdmin::add('carousel',
'<a href="./carousel/Admin/Slide/?carouselId=' . $carousel->id . '">Edit current slides</a>');
}
}
}
}

private function checkKey($key_id)
public function afterRun(Request $request, \Canopy\Response $response)
{
\Layout::addJSHeader('<script type="text/javascript" src="' . PHPWS_SOURCE_HTTP
. 'mod/carousel/javascript/add_slide.js"></script>');
$db = \phpws2\Database::newDB();
$t = $db->addTable('caro_keyed_slide');
$t->addField('slide_id');
$t->addFieldConditional('key_id', $key_id);
$result = $db->selectColumn();
if (\Current_User::allow('carousel')) {
$this->miniAdmin($result, $key_id);
if (version_compare($this->version, '2.0.0', '<')) {
return;
}
if (!empty($result)) {
\carousel\SlideFactory::showKeySlide($result);
$key = \Canopy\Key::getCurrent();
if ($key && !$key->isDummy() && !$key->isHomeKey()) {
if (\Current_User::allow('carousel')) {
$this->pinForm($key->id);
}
$this->viewPinned($key->id);
}
}

private function miniAdmin($result, $key_id)
private function viewPinned($keyId)
{
if (empty($result)) {
$db = \phpws2\Database::newDB();
$t2 = $db->addTable('caro_slide');
$t2->addOrderBy('title');
$t2->addField('title');
$t2->addField('id');
$slides = $db->select();
if (empty($slides)) {
return;
}

$opt[] = '<option id="0" style="">' . 'Add slide to this page' . '</option>';
foreach ($slides as $s) {
$opt[] = '<option value="' . $s['id'] . '">' . substr($s['title'],
0, 15) . '</option>';
}

$select = '<select data-key-id="' . $key_id . '" id="add-slide" style="font-size:12px" class="form-control">'
. implode("\n", $opt) . '</select>';
} else {
$select = '<a href="javascript:void(0)" id="remove-slide" data-key-id="' . $key_id . '">' . 'Remove slide from page' . '</a>';
}
\MiniAdmin::add('carousel', $select);
$carouselView = new View\CarouselView;
\Layout::add($carouselView->viewPinned($keyId), 'carousel', 'slides');
}

public function getSettingDefaults()
private function pinForm($keyId)
{
$s['min_width'] = 1000;
$s['min_height'] = 100;
$s['iteration'] = 0;
$s['time_interval'] = 5;
$s['display_mobile'] = false;
// transition 0 slide, 1 fade
$s['transition'] = 0;
$s['indicator'] = 0;
return $s;
$carouselView = new View\CarouselView;
$content = $carouselView->miniAdmin($keyId);
\MiniAdmin::add('carousel', $content);
}

}
Expand Down
153 changes: 153 additions & 0 deletions boost/Version2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<?php

/**
* MIT License
* Copyright (c) 2019 Electronic Student Services @ Appalachian State University
*
* See LICENSE file in root directory for copyright and distribution permissions.
*
* @author Matthew McNaney <mcnaneym@appstate.edu>
* @license https://opensource.org/licenses/MIT
*/
class Version2
{

private $previousSettings;

public function __construct()
{
$this->loadPreviousSettings();
}

public function runUpdate()
{
$this->updateControlpanel();
$this->createCarouselTable();
$this->createThumbnailDirectory();
$this->createPinTable();
$this->updateSlideTable();
$carouselId = $this->createFirstCarousel();
$this->updateSlides($carouselId);
}

private function createPinTable()
{
$db = \phpws2\Database::getDB();
$caroPin = $db->buildTable('caro_pin');
$ci = $caroPin->addDataType('carouselId', 'int');
$ki = $caroPin->addDataType('keyId', 'int');
$caroPin->create();
$unique = new \phpws2\Database\Unique([$ci, $ki]);
$unique->add();
}

private function updateControlpanel()
{
$db = \phpws2\Database::getDB();
$tbl = $db->addTable('controlpanel_link');
$tbl->addValue('url', 'carousel/Admin/Carousel');
$tbl->addFieldConditional('itemname', 'carousel');
$db->update();
}

private function createCarouselTable()
{
$db = \phpws2\Database::getDB();
$carousel = new \carousel\Resource\CarouselResource();
$carousel->createTable($db);
}

private function loadPreviousSettings()
{
$db = \phpws2\Database::getDB();
$settings = $db->addTable('settings');
$settings->addFieldConditional('module_name', 'carousel');
$result = $db->select();
if (empty($result)) {
return;
}
foreach ($result as $set) {
$this->previousSettings[$set['variable_name']] = $set['setting'];
}
}

private function createFirstCarousel()
{
$factory = new \carousel\Factory\CarouselFactory;
$carousel = $factory->build();
$carousel->title = 'First Carousel';
$carousel->iterations = $this->previousSettings['iteration'];
if ($carousel->iterations > 3) {
$carousel->iterations = 3;
}
$carousel->intervalTime = $this->previousSettings['time_interval'];
if ($carousel->intervalTime % 2) {
$carousel->intervalTime = $carousel->intervalTime + 1;
}
$carousel->transition = $this->previousSettings['transition'];
$carousel->indicator = $this->previousSettings['indicator'];
$carousel->frontpage = true;
$factory->save($carousel);
return $carousel->id;
}

private function createThumbnailDirectory()
{
$imgDirectory = PHPWS_HOME_DIR . 'images/carousel/thumbnail/';
if (!is_dir($imgDirectory)) {
mkdir($imgDirectory);
}
}

private function updateSlideTable()
{
$db = \phpws2\Database::getDB();
$tbl = $db->addTable('caro_slide');
$width = new \phpws2\Database\Datatype\Smallint($tbl, 'width');
$width->add();
$height = new \phpws2\Database\Datatype\Smallint($tbl, 'height');
$height->add();
$type = new \phpws2\Database\Datatype\Smallint($tbl, 'type');
$type->add();
$carouselId = new \phpws2\Database\Datatype\Integer($tbl, 'carouselId');
$carouselId->setDefault(0);
$carouselId->add();
$thumbnail = new \phpws2\Database\Datatype\Varchar($tbl, 'thumbnail');
$thumbnail->setSize(255);
$thumbnail->add();
$opacity = new \phpws2\Database\Datatype\Smallint($tbl, 'opacity');
$opacity->setDefault(50);
$opacity->add();
}

private function moveThumbnail($slide)
{
$filepath = $slide->filepath;
$oldThumbnailPath = preg_replace('/\.(png|jpeg)$/', '_tn.\\1', $filepath);
$pathArray = explode('/', $oldThumbnailPath);
$thumbnailFile = array_pop($pathArray);
$newPath = PHPWS_HOME_DIR . 'images/carousel/thumbnail/' . $thumbnailFile;
copy($oldThumbnailPath, $newPath);
unlink($oldThumbnailPath);
return 'images/carousel/thumbnail/' . $thumbnailFile;
}

private function updateSlides($carouselId)
{
$db = \phpws2\Database::getDB();
$tbl = $db->addTable('caro_slide');
$slides = $db->selectAsResources('\\carousel\\Resource\\SlideResource');

foreach ($slides as $slide) {
$dim = getimagesize($slide->filepath);
$slide->width = $dim[0];
$slide->height = $dim[1];
$slide->type = 0;
$slide->carouselId = $carouselId;
$newPath = $this->moveThumbnail($slide);
$slide->thumbnail = $newPath;
\carousel\Factory\SlideFactory::saveResource($slide);
}
}

}
2 changes: 1 addition & 1 deletion boost/boost.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author Matthew McNaney <mcnaneym@appstate.edu>
*/
$proper_name = 'Carousel for Bootstrap';
$version = '1.5.1';
$version = '2.0.0';
$import_sql = false;
$image_dir = true;
?>
2 changes: 1 addition & 1 deletion boost/controlpanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
$link[] = array('label' => 'Carousel',
'restricted' => TRUE,
'url' => 'carousel/admin/',
'url' => 'carousel/Admin/Carousel',
'description' => 'Image carousel for Bootstrap themes',
'image' => 'carousel.gif',
'tab' => 'content'
Expand Down
Loading