1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Simple Gallery plugin which uses the media-manager back-end.

This commit is contained in:
CaMer0n 2012-04-23 01:15:31 +00:00
parent c6951802cd
commit 0733253516
9 changed files with 466 additions and 0 deletions

View File

@ -0,0 +1,34 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/download/admin_download.php,v $
* $Revision: 12639 $
* $Date: 2012-04-20 00:28:53 -0700 (Fri, 20 Apr 2012) $
* $Author: e107coders $
*/
$eplug_admin = true;
require_once("../../class2.php");
if (!getperms("P") || !plugInstalled('gallery'))
{
header("location:".e_BASE."index.php");
exit() ;
}
$e_sub_cat = 'gallery';
new plugin_gallery_admin();
require_once(e_ADMIN."auth.php");
e107::getAdminUI()->runPage(); //gallery/includes/admin.php is auto-loaded.
require_once(e_ADMIN."footer.php");
exit;
?>

View File

@ -0,0 +1,102 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Cron Administration
*
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_admin/cron.php $
* $Id: cron.php 12492 2011-12-30 16:09:10Z e107steved $
*
*/
/**
*
* @package e107
* @subpackage frontend
* @version $Id: cron.php 12492 2011-12-30 16:09:10Z e107steved $
* Ultra-simple Image-Gallery
*/
/*
* THIS SCRIPT IS HIGHLY EXPERIMENTAL. USE AT OWN RISK.
*
*/
require_once("../../class2.php");
if (!getperms("P") || !plugInstalled('gallery'))
{
header('location:'.e_BASE.'index.php');
exit;
}
require_once(HEADERF);
class gallery
{
private $catList = array();
function __construct()
{
$this->catList = e107::getMedia()->getCategories('gallery');
if(($_GET['cat']) && isset($this->catList[$_GET['cat']]))
{
$this->showImages($_GET['cat']);
}
else
{
$this->listCategories();
}
}
function listCategories()
{
$template = e107::getTemplate('gallery');
$sc = e107::getScBatch('gallery',TRUE);
$text = "";
foreach($this->catList as $val)
{
$sc->setParserVars($val);
$text .= e107::getParser()->parseTemplate($template['CAT_ITEM'],TRUE);
}
$text = $template['CAT_START'].$text.$template['CAT_END'];
e107::getRender()->tablerender("Gallery",$text);
}
//TODO Shadowbox/Popup support.
function showImages($cat)
{
$mes = e107::getMessage();
$template = e107::getTemplate('gallery');
$list = e107::getMedia()->getImages($cat);
$sc = e107::getScBatch('gallery',TRUE);
$text = "";
foreach($list as $row)
{
$sc->setParserVars($row);
$text .= e107::getParser()->parseTemplate($template['LIST_ITEM'],TRUE);
}
$text = $template['LIST_START'].$text.$template['LIST_END'];
e107::getRender()->tablerender("Gallery :: ".str_replace("_"," ",$cat),$mes->render().$text);
}
}
new gallery;
require_once(FOOTERF);
exit;
?>

View File

@ -0,0 +1,53 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Custom download install/uninstall/update routines
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/download/download_setup.php,v $
* $Revision: 12639 $
* $Date: 2012-04-20 00:28:53 -0700 (Fri, 20 Apr 2012) $
* $Author: e107coders $
*
*/
class gallery_setup
{
function install_pre($var)
{
// print_a($var);
$mes = eMessage::getInstance();
// $mes->add("custom install 'pre' function.", E_MESSAGE_SUCCESS);
}
function install_post($var)
{
$sql = e107::getDb();
$mes = eMessage::getInstance();
// $mes->add("custom install 'post' function.", E_MESSAGE_SUCCESS);
}
function uninstall_pre($var)
{
$sql = e107::getDb();
$mes = eMessage::getInstance();
// $mes->add("custom uninstall 'pre' function.", E_MESSAGE_SUCCESS);
}
// IMPORTANT : This function below is for modifying the CONTENT of the tables only, NOT the table-structure.
// To Modify the table-structure, simply modify your {plugin}_sql.php file and an update will be detected automatically.
/*
* @var $needed - true when only a check for a required update is being performed.
* Return: Reason the upgrade is required, otherwise set it to return FALSE.
*/
function upgrade_post($needed)
{
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,173 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Download Plugin Administration UI
*
* $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_plugins/release/includes/admin.php $
* $Id: admin.php 12212 2011-05-11 22:25:02Z e107coders $
*/
//require_once(e_HANDLER.'admin_handler.php'); - autoloaded - see class2.php __autoload()
// new media_admin();
class plugin_gallery_admin extends e_admin_dispatcher
{
/**
* Format: 'MODE' => array('controller' =>'CONTROLLER_CLASS'[, 'index' => 'list', 'path' => 'CONTROLLER SCRIPT PATH', 'ui' => 'UI CLASS NAME child of e_admin_ui', 'uipath' => 'UI SCRIPT PATH']);
* Note - default mode/action is autodetected in this order:
* - $defaultMode/$defaultAction (owned by dispatcher - see below)
* - $adminMenu (first key if admin menu array is not empty)
* - $modes (first key == mode, corresponding 'index' key == action)
* @var array
*/
protected $modes = array (
'main' => array (
'controller' => 'gallery_cat_admin_ui',
'path' => null,
'ui' => 'gallery_cat_admin_form_ui',
'uipath' => null
),
'cat' => array (
'controller' => 'gallery_cat_ui',
'path' => null,
'ui' => 'gallery_cat_form_ui',
'uipath' => null
)
);
/* Both are optional
protected $defaultMode = null;
protected $defaultAction = null;
*/
/**
* Format: 'MODE/ACTION' => array('caption' => 'Menu link title'[, 'url' => '{e_PLUGIN}release/admin_config.php', 'perm' => '0']);
* Additionally, any valid e_admin_menu() key-value pair could be added to the above array
* @var array
*/
protected $adminMenu = array(
// 'main/list' => array('caption'=> LAN_CATEGORY, 'perm' => 'P'),
// 'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'),
'main/gallery' => array('caption'=> 'Info', 'perm' => 'P')//, 'url'=>'{e_ADMIN}image.php'
);
/**
* Optional, mode/action aliases, related with 'selected' menu CSS class
* Format: 'MODE/ACTION' => 'MODE ALIAS/ACTION ALIAS';
* This will mark active main/list menu item, when current page is main/edit
* @var array
*/
protected $adminMenuAliases = array(
/// 'main/edit' => 'main/list',
// 'cat/edit' => 'cat/list'
);
/**
* Navigation menu title
* @var string
*/
protected $menuTitle = 'Gallery';
}
class gallery_cat_admin_ui extends e_admin_ui
{
protected $pluginTitle = 'Gallery Categories';
protected $pluginName = 'gallery';
protected $table = "core_media_cat";
protected $pid = "media_cat_id";
protected $perPage = 10; //no limit
protected $listOrder = 'media_cat_order';
protected $listQry = "SELECT * FROM #core_media_cat WHERE media_cat_owner = 'gallery' "; // without any Order or Limit.
// protected $editQry = "SELECT * FROM #faq_info WHERE faq_info_id = {ID}";
protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
// 'media_cat_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE, 'readonly'=>TRUE),
'media_cat_image' => array('title'=> LAN_IMAGE, 'type' => 'image', 'data' => 'str', 'width' => '100px', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','readonly'=>FALSE, 'batch' => FALSE, 'filter'=>FALSE),
'media_cat_owner' => array('title'=> "Owner", 'type' => 'hidden', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE, 'writeParms' =>'value=gallery'),
'media_cat_category' => array('title'=> LAN_CATEGORY, 'type' => 'hidden', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE),
'media_cat_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE),
'media_cat_diz' => array('title'=> LAN_DESCRIPTION, 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=150&bb=1','readonly'=>FALSE), // Display name
'media_cat_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'width' => 'auto', 'data' => 'int', 'filter'=>TRUE, 'batch'=>TRUE),
'media_cat_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => '5%', 'thclass' => 'right', 'class'=> 'right' ),
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
);
public function beforeCreate($new_data)
{
$replace = array("_"," ","'",'"',"."); //FIXME Improve
$new_data['media_cat_category'] = strtolower(str_replace($replace,"",$new_data['media_cat_title']));
return $new_data;
}
function galleryPage()
{
$mes = e107::getMessage();
$message = "<b>Gallery</b> is active. Simply import and assign images to the gallery categories using the <a href='".e_ADMIN."image.php'>Media Manager</a>";
$mes->addInfo($message);
}
}
class gallery_cat_admin_form_ui extends e_admin_form_ui
{
// Override the default Options field.
public function gallery_category_parent($curVal,$mode)
{
// TODO - catlist combo without current cat ID in write mode, parents only for batch/filter
// Get UI instance
$controller = $this->getController();
switch($mode)
{
case 'read':
return e107::getParser()->toHTML($controller->getDownloadCategoryTree($curVal), false, 'TITLE');
break;
case 'write':
return $this->selectbox('gallery_category_parent', $controller->getDownloadCategoryTree(), $curVal);
break;
case 'filter':
case 'batch':
return $controller->getDownloadCategoryTree();
break;
}
}
}
class gallery_main_admin_ui extends e_admin_ui
{
}
class gallery_main_admin_form_ui extends e_admin_form_ui
{
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: plugin.xml,v 1.15 2009-10-22 04:14:45 e107coders Exp $ -->
<e107Plugin name="Gallery" version="1.0" compatibility="0.8" installRequired="true" releaseUrl=''>
<author name="e107 Inc." url="http://e107.org" />
<description>Gallery</description>
<category>content</category>
<languageFiles>
<file type='install' path='languages/--LAN--/admin_gallery.php' />
</languageFiles>
<adminLinks>
<link url='admin_gallery.php' description='LAN_CONFIGURE' icon='images/dgallery_32.png' iconSmall='images/gallery_16.png' primary='true' >LAN_CONFIGURE</link>
</adminLinks>
<siteLinks>
<link url="{e_PLUGIN}gallery/gallery.php" sef="gallery" perm="everyone" >Gallery</link>
</siteLinks>
<mainPrefs>
</mainPrefs>
</e107Plugin>

View File

@ -0,0 +1,44 @@
<?php
/*
* Copyright (c) e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: e_shortcode.php 12438 2011-12-05 15:12:56Z secretr $
*
* Featurebox shortcode batch class - shortcodes available site-wide. ie. equivalent to multiple .sc files.
*/
if (!defined('e107_INIT')) { exit; }
class gallery_shortcodes extends e_shortcode
{
function sc_gallery_caption($parm='')
{
return $this->eParserVars['media_caption'];
}
function sc_gallery_thumb($parm='')
{
$att = ($parm) ?$parm : 'aw=190&ah=150';
return "<img src='".e107::getParser()->thumbUrl($this->eParserVars['media_url'],$att)."' alt='' />";
}
function sc_gallery_cat_title($parm='')
{
$tp = e107::getParser();
$text = "<a href='".e_SELF."?cat=".$this->eParserVars['media_cat_category']."'>";
$text .= $tp->toHtml($this->eParserVars['media_cat_title']);
$text .= "</a>";
return $text;
}
function sc_gallery_cat_thumb($parm='')
{
$att = ($parm) ?$parm : 'aw=190&ah=150';
$text = "<a href='".e_SELF."?cat=".$this->eParserVars['media_cat_category']."'>";
$text .= "<img src='".e107::getParser()->thumbUrl($this->eParserVars['media_cat_image'],$att)."' alt='' />";
$text .= "</a>";
return $text;
}
}

View File

@ -0,0 +1,42 @@
<?php
$GALLERY_TEMPLATE['LIST_START'] =
"<div class='gallery-list-start' style='clear:both'>";
$GALLERY_TEMPLATE['LIST_ITEM'] =
"<div style='width:190px;height:180px;float:left;margin:3px;border:1px solid black;background-color:black'>
<div>{GALLERY_THUMB}</div>
<div style='display:block;text-align:center;color:white;'>{GALLERY_CAPTION}</div>
</div>
";
$GALLERY_TEMPLATE['LIST_END'] =
"</div>
<div class='gallery-list-end' style='text-align:center;clear:both'>
<a href='".e_SELF."'>Back to Categories</a>
</div>
";
$GALLERY_TEMPLATE['CAT_START'] =
"<div class='gallery-cat-start' style='clear:both'>";
$GALLERY_TEMPLATE['CAT_ITEM'] =
"<div style='width:190px;height:180px;float:left;margin:3px;border:1px solid black;background-color:black'>
<div>{GALLERY_CAT_THUMB}</div>
<div style='text-align:center'><h3>{GALLERY_CAT_TITLE}</h3></div>
</div>
";
$GALLERY_TEMPLATE['CAT_END'] =
"</div>
<div class='gallery-cat-end' style='text-align:center;clear:both'>
</div>
";
?>