From 07332535163228eda75a64c2fb8d81c08b608987 Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Mon, 23 Apr 2012 01:15:31 +0000 Subject: [PATCH] Simple Gallery plugin which uses the media-manager back-end. --- e107_plugins/gallery/admin_gallery.php | 34 ++++ e107_plugins/gallery/gallery.php | 102 +++++++++++ e107_plugins/gallery/gallery_setup.php | 53 ++++++ e107_plugins/gallery/images/gallery_16.png | Bin 0 -> 1075 bytes e107_plugins/gallery/images/gallery_32.png | Bin 0 -> 2770 bytes e107_plugins/gallery/includes/admin.php | 173 ++++++++++++++++++ e107_plugins/gallery/plugin.xml | 18 ++ .../shortcodes/batch/gallery_shortcodes.php | 44 +++++ .../gallery/templates/gallery_template.php | 42 +++++ 9 files changed, 466 insertions(+) create mode 100644 e107_plugins/gallery/admin_gallery.php create mode 100644 e107_plugins/gallery/gallery.php create mode 100644 e107_plugins/gallery/gallery_setup.php create mode 100644 e107_plugins/gallery/images/gallery_16.png create mode 100644 e107_plugins/gallery/images/gallery_32.png create mode 100644 e107_plugins/gallery/includes/admin.php create mode 100644 e107_plugins/gallery/plugin.xml create mode 100644 e107_plugins/gallery/shortcodes/batch/gallery_shortcodes.php create mode 100644 e107_plugins/gallery/templates/gallery_template.php diff --git a/e107_plugins/gallery/admin_gallery.php b/e107_plugins/gallery/admin_gallery.php new file mode 100644 index 000000000..3ae513788 --- /dev/null +++ b/e107_plugins/gallery/admin_gallery.php @@ -0,0 +1,34 @@ +runPage(); //gallery/includes/admin.php is auto-loaded. + require_once(e_ADMIN."footer.php"); + exit; + + +?> \ No newline at end of file diff --git a/e107_plugins/gallery/gallery.php b/e107_plugins/gallery/gallery.php new file mode 100644 index 000000000..f94ecdd32 --- /dev/null +++ b/e107_plugins/gallery/gallery.php @@ -0,0 +1,102 @@ +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; + + +?> \ No newline at end of file diff --git a/e107_plugins/gallery/gallery_setup.php b/e107_plugins/gallery/gallery_setup.php new file mode 100644 index 000000000..652a90e3d --- /dev/null +++ b/e107_plugins/gallery/gallery_setup.php @@ -0,0 +1,53 @@ +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) + { + + } +} diff --git a/e107_plugins/gallery/images/gallery_16.png b/e107_plugins/gallery/images/gallery_16.png new file mode 100644 index 0000000000000000000000000000000000000000..7d7da74d288bc7e29ccc031bd42b6118f31eda35 GI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zV4}2!aRTghjyRNvJo{rGPv&cS_4Aiku*ptYxend%#yHW16JDICE31R#0vz}1R*%z(Zr z(wQ=iyLJY}X~c#*8+L+guKqQI(O?5Rs@vP!!#xsKo3=b{j`iUH{7pb77d46x8Ai{M zGll-!w$(PATfij&w)$0-M41d*Utgam$~x=iQwyNdFXA{v;Mqpai4g1Fw{IUPQ 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 = "Gallery is active. Simply import and assign images to the gallery categories using the Media Manager"; + + $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 +{ + + + + +} diff --git a/e107_plugins/gallery/plugin.xml b/e107_plugins/gallery/plugin.xml new file mode 100644 index 000000000..4c24452d2 --- /dev/null +++ b/e107_plugins/gallery/plugin.xml @@ -0,0 +1,18 @@ + + + + + Gallery + content + + + + + LAN_CONFIGURE + + + Gallery + + + + diff --git a/e107_plugins/gallery/shortcodes/batch/gallery_shortcodes.php b/e107_plugins/gallery/shortcodes/batch/gallery_shortcodes.php new file mode 100644 index 000000000..2e55afb1c --- /dev/null +++ b/e107_plugins/gallery/shortcodes/batch/gallery_shortcodes.php @@ -0,0 +1,44 @@ +eParserVars['media_caption']; + } + + function sc_gallery_thumb($parm='') + { + $att = ($parm) ?$parm : 'aw=190&ah=150'; + return ""; + } + + function sc_gallery_cat_title($parm='') + { + $tp = e107::getParser(); + $text = ""; + $text .= $tp->toHtml($this->eParserVars['media_cat_title']); + $text .= ""; + return $text; + } + + function sc_gallery_cat_thumb($parm='') + { + $att = ($parm) ?$parm : 'aw=190&ah=150'; + $text = ""; + $text .= ""; + $text .= ""; + return $text; + } + + +} diff --git a/e107_plugins/gallery/templates/gallery_template.php b/e107_plugins/gallery/templates/gallery_template.php new file mode 100644 index 000000000..77257a977 --- /dev/null +++ b/e107_plugins/gallery/templates/gallery_template.php @@ -0,0 +1,42 @@ +"; + + +$GALLERY_TEMPLATE['LIST_ITEM'] = + "
+
{GALLERY_THUMB}
+
{GALLERY_CAPTION}
+
+ "; + +$GALLERY_TEMPLATE['LIST_END'] = + " + + "; + + +$GALLERY_TEMPLATE['CAT_START'] = + " + + "; + + +?> \ No newline at end of file