* @project ApPHP Business Directory * @copyright (c) 2011 ApPHP * @author ApPHP <*****@*****.**> * @license http://www.gnu.org/licenses/ */ // *** Make sure the file isn't accessed directly defined('APPHP_EXEC') or die('Restricted Access'); //-------------------------------------------------------------------------- if ($objLogin->IsLoggedInAsAdmin() && Modules::IsModuleInstalled('gallery')) { $action = MicroGrid::GetParameter('action'); $rid = MicroGrid::GetParameter('rid'); $album = MicroGrid::GetParameter('album', false); $mode = 'view'; $msg = ''; $objAlbums = new GalleryAlbums(); $album_info = $objAlbums->GetAlbumInfo($album); if (count($album_info) > 0) { $objAlbumItems = new GalleryAlbumItems(); if ($action == 'add') { $mode = 'add'; } else { if ($action == 'create') { if ($objAlbumItems->AddRecord()) { $msg = draw_success_message(_ADDING_OPERATION_COMPLETED, false); $mode = 'view'; } else { $msg = draw_important_message($objAlbumItems->error, false); $mode = 'add'; } } else { if ($action == 'edit') {
function __construct() { parent::__construct(); global $objLogin; $album = MicroGrid::GetParameter('album', false); $objAlbums = new GalleryAlbums(); $album_info = $objAlbums->GetAlbumInfo($album); $this->params = array(); if (isset($_POST['album_code'])) { $this->params['album_code'] = prepare_input($_POST['album_code']); } if (isset($_POST['priority_order'])) { $this->params['priority_order'] = prepare_input($_POST['priority_order']); } if (isset($_POST['is_active'])) { $this->params['is_active'] = prepare_input($_POST['is_active']); } else { $this->params['is_active'] = '0'; } if ($album_info[0]['album_type'] == 'video') { if (isset($_POST['item_file'])) { $this->params['item_file'] = prepare_input($_POST['item_file']); if ($this->params['item_file'] != '' && !preg_match('/^http:\\/\\/i/', $this->params['item_file'])) { $this->params['item_file'] = 'http://' . $this->params['item_file']; } } if (isset($_POST['item_file_thumb'])) { $this->params['item_file_thumb'] = prepare_input($_POST['item_file_thumb'], false, 'medium'); } } ///$this->params['language_id'] = MicroGrid::GetParameter('language_id'); $icon_width = ModulesSettings::Get('gallery', 'album_icon_width') != '' ? ModulesSettings::Get('gallery', 'album_icon_width') : '120px'; $icon_height = ModulesSettings::Get('gallery', 'album_icon_height') != '' ? ModulesSettings::Get('gallery', 'album_icon_height') : '90px'; $this->primaryKey = 'id'; $this->tableName = TABLE_GALLERY_ALBUM_ITEMS; $this->dataSet = array(); $this->error = ''; $this->formActionURL = 'index.php?admin=mod_gallery_upload_items&album=' . $album; $this->actions = array('add' => true, 'edit' => true, 'details' => true, 'delete' => true); $this->actionIcons = true; $this->allowRefresh = true; $this->allowTopButtons = true; $this->allowLanguages = false; $this->languageId = $objLogin->GetPreferredLang(); $this->WHERE_CLAUSE = 'WHERE album_code = \'' . $album . '\''; $this->ORDER_CLAUSE = 'ORDER BY priority_order ASC'; // ORDER BY date_created DESC $this->isAlterColorsAllowed = true; $this->isPagingAllowed = true; $this->pageSize = 20; $this->isSortingAllowed = true; $this->isFilteringAllowed = false; // define filtering fields $this->arrFilteringFields = array(); /////////////////////////////////////////////////////////////////////////////// // 1. prepare translation fields array $this->arrTranslations = $this->PrepareTranslateFields(array('name', 'description')); /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // 2. prepare translations array for edit/detail modes $sql_translation_description = $this->PrepareTranslateSql(TABLE_GALLERY_ALBUM_ITEMS_DESCRIPTION, 'gallery_album_item_id', array('name', 'description')); /////////////////////////////////////////////////////////////////////////////// $arr_is_active = array('0' => '<span class=no>' . _NO . '</span>', '1' => '<span class=yes>' . _YES . '</span>'); $help_tooltip = '<br><img src=\'' . APPHP_BASE . 'images/question_mark.png\' alt=\'\' /> Ex.: http://www.youtube.com/watch?v=5VIV8nt2KkU - or - http://localhost/{your site}/my_video.wmv'; //---------------------------------------------------------------------- // VIEW MODE //---------------------------------------------------------------------- $this->VIEW_MODE_SQL = 'SELECT gi.' . $this->primaryKey . ', gi.album_code, gi.item_file, gi.item_file_thumb, gi.priority_order, gi.is_active, gid.name, gid.description FROM (' . $this->tableName . ' gi LEFT OUTER JOIN ' . TABLE_GALLERY_ALBUM_ITEMS_DESCRIPTION . ' gid ON gi.id = gid.gallery_album_item_id AND gid.language_id = \'' . $this->languageId . '\')'; // define view mode fields if ($album_info[0]['album_type'] == 'video') { $this->arrViewModeFields['name'] = array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '20%', 'maxlength' => '30'); $this->arrViewModeFields['item_file'] = array('title' => _VIDEO, 'type' => 'label', 'align' => 'left', 'width' => '40%'); } else { $this->arrViewModeFields['item_file_thumb'] = array('title' => _IMAGE, 'type' => 'image', 'align' => 'left', 'width' => '60px', 'sortable' => false, 'nowrap' => '', 'visible' => '', 'image_width' => '50px', 'image_height' => '30px', 'target' => 'images/gallery/', 'no_image' => 'no_image.png'); $this->arrViewModeFields['name'] = array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '20%', 'maxlength' => '30'); } $this->arrViewModeFields['description'] = array('title' => _DESCRIPTION, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '60'); $this->arrViewModeFields['priority_order'] = array('title' => _ORDER, 'type' => 'label', 'align' => 'center', 'width' => '10%', 'movable' => true); $this->arrViewModeFields['is_active'] = array('title' => _ACTIVE, 'type' => 'enum', 'align' => 'center', 'width' => '10%', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'source' => $arr_is_active); //---------------------------------------------------------------------- // ADD MODE //---------------------------------------------------------------------- // define add mode fields $this->arrAddModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'priority_order' => array('title' => _ORDER, 'type' => 'textbox', 'width' => '60px', 'maxlength' => '3', 'required' => true, 'readonly' => false, 'validation_type' => 'numeric'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0'), 'album_code' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $album))); if ($album_info[0]['album_type'] == 'video') { $this->arrAddModeFields['separator_general']['item_file'] = array('title' => _VIDEO . ' (http://)', 'type' => 'textbox', 'width' => '370px', 'maxlength' => '255', 'required' => false, 'readonly' => false, 'validation_type' => '', 'post_html' => $help_tooltip); $this->arrAddModeFields['separator_general']['item_file_thumb'] = array('title' => _THUMBNAIL . ' (http://)', 'type' => 'textbox', 'width' => '370px', 'maxlength' => '255', 'required' => false, 'readonly' => false, 'validation_type' => ''); } else { $this->arrAddModeFields['separator_general']['item_file'] = array('title' => _IMAGE, 'type' => 'image', 'width' => '210px', 'required' => true, 'readonly' => false, 'target' => 'images/gallery/', 'thumbnail_create' => true, 'thumbnail_field' => 'item_file_thumb', 'thumbnail_width' => $icon_width, 'thumbnail_height' => $icon_height, 'file_maxsize' => '900k'); } //---------------------------------------------------------------------- // EDIT MODE //---------------------------------------------------------------------- $this->EDIT_MODE_SQL = 'SELECT ' . $this->primaryKey . ', album_code, item_file, item_file_thumb, priority_order, ' . $sql_translation_description . ' is_active FROM ' . $this->tableName . ' WHERE ' . $this->primaryKey . ' = _RID_'; // define edit mode fields $this->arrEditModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'priority_order' => array('title' => _ORDER, 'type' => 'textbox', 'width' => '60px', 'maxlength' => '3', 'required' => true, 'readonly' => false, 'validation_type' => 'numeric'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'true_value' => '1', 'false_value' => '0'), 'album_code' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $album))); if ($album_info[0]['album_type'] == 'video') { $this->arrEditModeFields['separator_general']['item_file'] = array('title' => _VIDEO . ' (http://) ', 'type' => 'textbox', 'width' => '370px', 'maxlength' => '255', 'required' => false, 'readonly' => false, 'validation_type' => '', 'post_html' => $help_tooltip); $this->arrEditModeFields['separator_general']['item_file_thumb'] = array('title' => _THUMBNAIL . ' (http://)', 'type' => 'textbox', 'width' => '370px', 'maxlength' => '255', 'required' => false, 'readonly' => false, 'validation_type' => ''); } else { $this->arrEditModeFields['separator_general']['item_file'] = array('title' => _IMAGE, 'type' => 'image', 'width' => '210px', 'required' => true, 'readonly' => false, 'target' => 'images/gallery/', 'thumbnail_create' => true, 'thumbnail_field' => 'item_file_thumb', 'thumbnail_width' => $icon_width, 'thumbnail_height' => $icon_height, 'file_maxsize' => '900k'); } //---------------------------------------------------------------------- // DETAILS MODE //---------------------------------------------------------------------- $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL; $this->arrDetailsModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'priority_order' => array('title' => _ORDER, 'type' => 'label'), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'source' => $arr_is_active))); if ($album_info[0]['album_type'] == 'video') { $this->arrDetailsModeFields['separator_general']['item_file'] = array('title' => _VIDEO, 'type' => 'object', 'width' => '240px', 'height' => '200px'); $this->arrDetailsModeFields['separator_general']['item_file_thumb'] = array('title' => _THUMBNAIL, 'type' => 'label'); } else { $this->arrDetailsModeFields['separator_general']['item_file'] = array('title' => _IMAGE, 'type' => 'image', 'target' => 'images/gallery/', 'no_image' => 'no_image.png'); } /////////////////////////////////////////////////////////////////////////////// // 3. add translation fields to all modes $this->AddTranslateToModes($this->arrTranslations, array('name' => array('title' => _NAME, 'type' => 'textbox', 'width' => '410px', 'required' => false, 'maxlength' => '125', 'readonly' => false), 'description' => array('title' => _DESCRIPTION, 'type' => 'textarea', 'width' => '410px', 'height' => '70px', 'required' => false, 'maxlength' => '255', 'validation_maxlength' => '255', 'readonly' => false))); /////////////////////////////////////////////////////////////////////////////// }