primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,122 @@
<?php
/**
* @version $Id: accesslevel.php 20196 2011-01-09 02:40:25Z ian $
* @package Joomla.Framework
* @subpackage Form
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
jimport('joomla.html.html');
jimport('joomla.form.formfield');
jimport('joomla.form.helper');
FormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Framework.
*
* @package Joomla.Framework
* @subpackage Form
* @since 1.6
*/
class JFormFieldPhocaAccessLevel extends ListField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'AccessLevel';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
// Initialize variables.
$attr = '';
// Initialize some field attributes.
$attr .= $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : '';
$attr .= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
$attr .= $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
$attr .= $this->multiple ? ' multiple="multiple"' : '';
// Initialize JavaScript field attributes.
$attr .= $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
// Get the field options.
$options = $this->getOptions();
//return $this->_level( $this->name, $this->value, $attr, $options, $this->id);
$data = $this->getLayoutData();
$data['options'] = (array) $this->_level( $this->name, $this->value, $attr, $options, $this->id);
return $this->getRenderer($this->layout)->render($data);
}
public static function _level($name, $selected, $attribs = '', $params = true, $id = false) {
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select('a.id AS value, a.title AS text');
$query->from('#__viewlevels AS a');
//PHOCAEDIT
$query->where('a.id <> 1');
//ENDPHOCAEDIT
$query->group('a.id, a.title');
$query->order('a.ordering ASC');
$query->order('`title` ASC');
// Check for a database error.
/* if ($db->getErrorNum()) {
throw new Exception($db->getErrorMsg(), 500);
return false;
}*/
try {
// Get the options.
$db->setQuery($query);
$options = $db->loadObjectList();
} catch (RuntimeException $e) {
throw new Exception($e->getMessage(), 500);
return false;
}
// If params is an array, push these options to the array
if (is_array($params)) {
$options = array_merge($params,$options);
}
// If all levels is allowed, push it into the array.
elseif ($params) {
array_unshift($options, HTMLHelper::_('select.option', '', Text::_('JOPTION_ACCESS_SHOW_ALL_LEVELS')));
}
return $options;
/*
return HTMLHelper::_('select.genericlist', $options, $name,
array(
'list.attr' => $attribs,
'list.select' => $selected,
'id' => $id
)
);*/
}
}

View File

@ -0,0 +1,87 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined('JPATH_BASE') or die;
jimport('joomla.form.formfield');
class JFormFieldPhocaColorText extends JFormField
{
protected $type = 'PhocaColorText';
protected $phocaParams = null;
protected function getInput() {
$document = JFactory::getDocument();
$option = JFactory::getApplication()->input->getCmd('option');
$globalValue = $this->_getPhocaParams( $this->element['name'] );
JHTML::stylesheet( 'administrator/components/com_phocadownload/assets/jcp/picker.css' );
$document->addScript(JURI::base(true).'/components/com_phocadownload/assets/jcp/picker.js');
// Initialize some field attributes.
$size = $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
$class = $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : '';
$maxLength = $this->element['maxlength'] ? ' maxlength="'.(int) $this->element['maxlength'].'"' : '';
$readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
// Initialize JavaScript field attributes.
$onchange = $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
$value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
// TODO 1.6
// MENU - Set Default value to "" because of saving "" value into the menu link ( use global = "")
if ($option == "com_menus") {
$DefaultValue = (string)$this->element['default'];
if ($value == $DefaultValue) {
$value = '';
}
}
$html ='<input type="text" name="'.$this->name.'" id="'.$this->id.'" value="'.$value.'"'
.$class.$size.$disabled.$readonly.$onchange.$maxLength.'/>';
// Color Picker
$nameCP = str_replace('[', '_', $this->name);
$nameCP = str_replace(']', '', $nameCP);
$html .= '<span style="margin-left:10px" onclick="openPicker(\''.$nameCP.'\')" class="picker_buttons">' . JText::_('COM_PHOCADOWNLOAD_PICK_COLOR') . '</span>';
// MENU - Display the global value
if ($option == "com_menus") {
$html .= '<span style="margin-left:10px;">[</span><span style="background:#fff"> ' . $globalValue . ' </span><span>]</span>';
}
return $html;
}
protected function getLabel() {
echo '<div class="clearfix"></div>';
return parent::getLabel();
echo '<div class="clearfix"></div>';
}
protected function _setPhocaParams(){
$component = 'com_phocadownload';
$paramsC = JComponentHelper::getParams($component) ;
$this->phocaParams = $paramsC;
}
protected function _getPhocaParams( $name ){
// Don't call sql query by every param item (it will be loaded only one time)
if (!$this->phocaParams) {
$params = $this->_setPhocaParams();
}
$globalValue = $this->phocaParams->get( $name, '' );
return $globalValue;
}
}
?>

View File

@ -0,0 +1,205 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('_JEXEC') or die();
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
if (! class_exists('PhocaDownloadCategory')) {
require_once( JPATH_ADMINISTRATOR.'/components/com_phocadownload/libraries/phocadownload/category/category.php');
}
Factory::getApplication()->getLanguage()->load('com_phocadownload');
class JFormFieldPhocaDownloadCategory extends FormField
{
protected $type = 'PhocaDownloadCategory';
protected $layout = 'phocadownload.form.field.category';
protected function getRenderer($layoutId = 'default')
{
// Make field usable outside of Phoca Cart component
$renderer = parent::getRenderer($layoutId);
$renderer->addIncludePath(JPATH_ADMINISTRATOR . '/components/com_phocadownload/layouts');
return $renderer;
}
private function buildCategoryTree(array &$options, array $categories, string $treeTitle, array $typeFilter, array $langFilter, array $omitIds): void {
foreach ($categories as $category) {
if ($typeFilter && !in_array($category->type, $typeFilter)) continue;
if ($langFilter && !in_array($category->language, $langFilter)) continue;
if ($omitIds && in_array($category->id, $omitIds)) continue;
$title = ($treeTitle ? $treeTitle . ' - ' : '') . $category->title;
$options[] = (object)[
'text' => $title . ($category->language === '*' ? '' : ' (' . $category->language . ')'),
'value' => $category->id,
];
if ($category->children)
$this->buildCategoryTree($options, $category->children, $title, $typeFilter, $langFilter, $omitIds);
}
}
protected function getInput() {
$db = Factory::getDBO();
$multiple = (string)$this->element['multiple'] == 'true';
$typeMethod = $this->element['typemethod'];
switch($this->element['categorytype']) {
case 1:
$typeFilter = [0, 1];
break;
case 2:
$typeFilter = [0, 2];
break;
case 0:
default:
$typeFilter = [];
break;
}
if ($this->element['language']) {
$langFilter = explode(',', $this->element['language']);
} elseif ($this->form->getValue('language', 'filter')) {
$langFilter = [$this->form->getValue('language', 'filter')];
} else {
$langFilter = [];
}
// TO DO - check for other views than category edit
$omitIds = [];
switch (Factory::getApplication()->input->get('view')) {
case 'phocadownloadcategory':
if ($this->form->getValue('id') > 0)
$omitIds[] = $this->form->getValue('id');
break;
}
$db->setQuery('SELECT a.*, null AS children FROM #__phocadownload_categories AS a ORDER BY a.ordering, a.id');
$categories = $db->loadObjectList('id') ?? [];
array_walk($categories, function ($category) use ($categories) {
if ($category->parent_id) {
if ($categories[$category->parent_id]->children === null) {
$categories[$category->parent_id]->children = [];
}
$categories[$category->parent_id]->children[] = $category;
}
});
$rootCategories = array_filter($categories, function($category) {
return !$category->parent_id;
});
$options = [];
if ($multiple) {
if ($typeMethod == 'allnone') {
$options[] = HTMLHelper::_('select.option', '0', Text::_('COM_PHOCADOWNLOAD_NONE'), 'value', 'text');
$options[] = HTMLHelper::_('select.option', '-1', Text::_('COM_PHOCADOWNLOAD_ALL'), 'value', 'text');
}
} else {
// in filter we need zero value for canceling the filter
if ($typeMethod == 'menulink') {
// Required for menu link,
} else if ($typeMethod == 'filter') {
$options[] = HTMLHelper::_('select.option', '', '- ' . Text::_('COM_PHOCADOWNLOAD_SELECT_CATEGORY') . ' -', 'value', 'text');
} else {
$options[] = HTMLHelper::_('select.option', '0', '- '.Text::_('COM_PHOCADOWNLOAD_SELECT_CATEGORY').' -', 'value', 'text');
}
}
$this->buildCategoryTree($options, $rootCategories, '', $typeFilter, $langFilter, $omitIds);
$data = $this->getLayoutData();
$data['options'] = $options;
//if (!empty($activeCats)) {
// $data['value'] = $activeCats;
//} else {
$data['value'] = $this->value;
//}
$data['refreshPage'] = (bool)$this->element['refresh-enabled'];
$data['refreshCatId'] = (string)$this->element['refresh-cat-id'];
$data['refreshSection'] = (string)$this->element['refresh-section'];
$data['hasCustomFields']= !empty(FieldsHelper::getFields('com_phocadownload.phocadownloadfile'));
$document = Factory::getDocument();
$document->addCustomTag('<script type="text/javascript">
function changeCatid() {
/* var catid = document.getElementById(\'jform_catid\').value;*/
}
</script>');
return $this->getRenderer($this->layout)->render($data);
}
/*
protected function getInput() {
$db = Factory::getDBO();
//build the list of categories
$query = 'SELECT a.title AS text, a.id AS value, a.parent_id as parent_id'
. ' FROM #__phocadownload_categories AS a'
//. ' WHERE a.published = 1' // don't lose information about category when it will be unpublished - you should still be able to edit file with such category in administration
. ' ORDER BY a.ordering';
$db->setQuery( $query );
$data = $db->loadObjectList();
$view = Factory::getApplication()->input->get( 'view' );
$catId = -1;
if ($view == 'phocadownloadcat') {
$id = $this->form->getValue('id'); // id of current category
if ((int)$id > 0) {
$catId = $id;
}
}/*
if ($view == 'phocadownloadfile') {
$id = $this->form->getValue('catid'); // id of current category
if ((int)$id > 0) {
$catId = $id;
}
}*//*
//$required = ((string) $this->element['required'] == 'true') ? TRUE : FALSE;
$attr = '';
$attr .= $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
$attr .= $this->required ? ' required aria-required="true"' : '';
$attr .= ' class="form-select"';
$tree = array();
$text = '';
$tree = PhocaDownloadCategory::CategoryTreeOption($data, $tree, 0, $text, $catId);
//if ($required == TRUE) {
//} else {
array_unshift($tree, HTMLHelper::_('select.option', '', '- '.Text::_('COM_PHOCADOWNLOAD_SELECT_CATEGORY').' -', 'value', 'text'));
//}
return HTMLHelper::_('select.genericlist', $tree, $this->name, trim($attr), 'value', 'text', $this->value, $this->id );
}*/
}
?>

View File

@ -0,0 +1,128 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('JPATH_BASE') or die;
jimport('joomla.html.editor');
jimport('joomla.form.formfield');
class JFormFieldPhocaDownloadEditor extends JFormField
{
public $type = 'PhocaDownloadEditor';
protected $phocaParams = null;
protected $editor;
protected function getInput()
{
// Initialize some field attributes.
$rows = (int) $this->element['rows'];
$cols = (int) $this->element['cols'];
$height = ((string) $this->element['height']) ? (string) $this->element['height'] : '250';
$width = ((string) $this->element['width']) ? (string) $this->element['width'] : '100%';
// Build the buttons array.
$buttons = (string) $this->element['buttons'];
if ($buttons == 'true' || $buttons == 'yes' || $buttons == '1') {
$buttons = true;
} else if ($buttons == 'false' || $buttons == 'no' || $buttons == '0') {
$buttons = false;
} else {
$buttons = explode(',', $buttons);
}
$hide = ((string) $this->element['hide']) ? explode(',',(string) $this->element['hide']) : array();
$globalValue = $this->_getPhocaParameter( 'display_editor' );
if ($globalValue == '') {
$globalValue = 1;
}
$widthE = $width + 200;
if ($globalValue == 1) {
// Get an editor object.
$editor = $this->getEditor();
$editorOutput = '<div style="width:'.$widthE.'px">'. $editor->display($this->name, htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'), $width, $height, $cols, $rows, $buttons ? (is_array($buttons) ? array_merge($buttons,$hide) : $hide) : false, $this->id).'</div>';
return '<div style="clear:both;margin-top:5px"></div>' .$editorOutput;
}
else {
$style = '';
if ($width != '' && $height != '') {
$style = 'style="width:'.$width.'; height:'.$height.'"';
}
return '<textarea name="'.$this->name.'" cols="'.$cols.'" rows="'.$rows.'" '.$style.' id="'.$this->name.'" >'.htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8').'</textarea>';
}
}
protected function & getEditor()
{
// Only create the editor if it is not already created.
if (empty($this->editor)) {
// Initialize variables.
$editor = null;
// Get the editor type attribute. Can be in the form of: editor="desired|alternative".
$type = trim((string) $this->element['editor']);
if ($type) {
// Get the list of editor types.
$types = explode('|', $type);
// Get the database object.
$db = JFactory::getDBO();
// Iterate over teh types looking for an existing editor.
foreach ($types as $element) {
// Build the query.
$query = $db->getQuery(true);
$query->select('element');
$query->from('#__extensions');
$query->where('element = '.$db->quote($element));
$query->where('folder = '.$db->quote('editors'));
$query->where('enabled = 1');
// Check of the editor exists.
$db->setQuery($query, 0, 1);
$editor = $db->loadResult();
// If an editor was found stop looking.
if ($editor) {
break;
}
}
}
// Create the JEditor intance based on the given editor.
$this->editor = JFactory::getEditor($editor ? $editor : null);
}
return $this->editor;
}
public function save()
{
return $this->getEditor()->save($this->id);
}
protected function _setPhocaParams(){
$component = 'com_phocadownload';
$paramsC = JComponentHelper::getParams($component) ;
$this->phocaParams = $paramsC;
}
protected function _getPhocaParameter( $name ){
// Don't call sql query by every param item (it will be loaded only one time)
if (!$this->phocaParams) {
$params = $this->_setPhocaParams();
}
$globalValue = $this->phocaParams->get( $name, '' );
return $globalValue;
}
}

View File

@ -0,0 +1,51 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined('_JEXEC') or die();
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
class JFormFieldPhocaDownloadFile extends FormField
{
protected $type = 'PhocaDownloadFile';
protected function getInput() {
$db = Factory::getDBO();
//build the list of files
$query = 'SELECT a.title , a.id , a.catid'
. ' FROM #__phocadownload AS a'
. ' WHERE a.published = 1'
. ' ORDER BY a.ordering';
$db->setQuery( $query );
$messages = $db->loadObjectList();
$options = array();
if ($messages)
{
foreach($messages as $message)
{
$options[] = HTMLHelper::_('select.option', $message->id, $message->title);
}
}
$attr = '';
$attr .= $this->required ? ' required aria-required="true"' : '';
$attr .= ' class="form-control"';
array_unshift($options, HTMLHelper::_('select.option', '', '- '.Text::_('COM_PHOCADOWNLOAD_SELECT_FILE').' -', 'value', 'text'));
return HTMLHelper::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id );
}
}
?>

View File

@ -0,0 +1,41 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined('_JEXEC') or die();
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
class JFormFieldPhocaDownloadLicense extends FormField
{
protected $type = 'PhocaDownloadLicense';
protected function getInput() {
$db = Factory::getDBO();
//build the list of categories
$query = 'SELECT a.title AS text, a.id AS value'
. ' FROM #__phocadownload_licenses AS a'
//. ' WHERE a.published = 1'
. ' ORDER BY a.ordering';
$db->setQuery( $query );
$licenses = $db->loadObjectList();
$id = $this->form->getValue('id'); // id of current license
$required = ((string) $this->element['required'] == 'true') ? TRUE : FALSE;
array_unshift($licenses, HTMLHelper::_('select.option', '', '- '.Text::_('COM_PHOCADOWNLOAD_SELECT_LICENSE').' -', 'value', 'text'));
return HTMLHelper::_('select.genericlist', $licenses, $this->name, 'class="form-select"', 'value', 'text', $this->value, $this->id );
}
}
?>

View File

@ -0,0 +1,90 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\HTML\HTMLHelper;
jimport('joomla.html.html');
jimport('joomla.form.formfield');
class JFormFieldPhocaDownloadOrdering extends FormField
{
protected $type = 'PhocaDownloadOrdering';
protected function getInput() {
// Initialize variables.
$html = array();
$attr = '';
// Get some field values from the form.
$id = (int) $this->form->getValue('id');
if ($this->element['table']) {
switch (strtolower($this->element['table'])) {
case "category":
$whereLabel = 'parent_id';
$whereValue = (int) $this->form->getValue('parent_id');
$table = '#__phocadownload_categories';
break;
case "tag":
$whereLabel = '';
$whereValue = '';
$table = '#__phocadownload_tags';
break;
case "file":
default:
$whereLabel = 'catid';
$whereValue = (int) $this->form->getValue('catid');
$table = '#__phocadownload';
break;
}
} else {
$whereLabel = 'catid';
$whereValue = (int) $this->form->getValue('catid');
$table = '#__phocadownload';
}
// Initialize some field attributes.
$attr .= $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : '';
$attr .= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
$attr .= $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
// Initialize JavaScript field attributes.
$attr .= $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
// Build the query for the ordering list.
$query = 'SELECT ordering AS value, title AS text' .
' FROM ' . $table;
if ($whereLabel != '') {
$query .= ' WHERE '.$whereLabel.' = ' . (int) $whereValue;
}
$query .= ' ORDER BY ordering';
// Create a read-only list (no name) with a hidden input to store the value.
if ((string) $this->element['readonly'] == 'true') {
$html[] = HTMLHelper::_('list.ordering', '', $query, trim($attr), $this->value, $id ? 0 : 1);
$html[] = '<input type="hidden" name="'.$this->name.'" value="'.$this->value.'"/>';
}
// Create a regular list.
else {
$html[] = HTMLHelper::_('list.ordering', $this->name, $query, trim($attr), $this->value, $id ? 0 : 1);
}
return implode($html);
}
}

View File

@ -0,0 +1,53 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('_JEXEC') or die();
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Language\Text;
class JFormFieldPhocaDownloadToken extends FormField
{
protected $type = 'PhocaDownloadToken';
protected function getInput() {
//PhocaDownlooadUtils::getToken()
$salt = md5('string '. date('s'). mt_rand(0,9999) . str_replace(mt_rand(0,9), mt_rand(0,9999), date('r')). 'end string');
$token = hash('sha256', $salt . time());
// Initialize variables.
$html = array();
// Initialize some field attributes.
$size = $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
$maxLength = $this->element['maxlength'] ? ' maxlength="'.(int) $this->element['maxlength'].'"' : '';
$class = $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : '';
$readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
$maptype = ( (string)$this->element['maptype'] ? $this->element['maptype'] : '' );
// Initialize JavaScript field attributes.
$onchange = (string) $this->element['onchange'];
$onchangeOutput = ' onChange="'.(string) $this->element['onchange'].'"';
$html[] = '<div class="input-append input-group">';
$html[] = '<input type="text" id="'.$this->id.'_id" name="'.$this->name.'" value="'. $this->value.'"' .
' '.$class.$size.$disabled.$readonly.$onchangeOutput.$maxLength.' />';
$html[] = '<a class="btn btn-primary" title="'.Text::_('COM_PHOCADOWNLOAD_SET_TOKEN').'"'
.' href="javascript:void(0);"'
.' onclick="javascript:document.getElementById(\''.$this->id.'_id\').value = \''.$token.'\';return true;">'
. Text::_('COM_PHOCADOWNLOAD_SET_TOKEN').'</a>';
$html[] = '</div>'. "\n";
return implode("\n", $html);
}
}
?>

View File

@ -0,0 +1,61 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
jimport('joomla.html.html');
jimport('joomla.form.formfield');
class JFormFieldPhocaHead extends FormField
{
protected $type = 'PhocaHead';
protected function getLabel() { return '';}
protected function getInput() {
$tc = 'phocadownload';
//$ts = 'media/com_'.$tc.'/css/administrator/';
$ti = 'media/com_'.$tc.'/images/administrator/';
//HTMLHelper::stylesheet( $ts.'/'.$tc.'options.css' );
$app = Factory::getApplication();
$wa = $app->getDocument()->getWebAssetManager();
$option = 'com_phocadownload';
$wa->registerAndUseStyle($option . '.options', 'media/' .$option . '/css/administrator/phocadownloadoptions.css', array('version' => 'auto'));
$wa->registerAndUseStyle($option . '.theme', 'media/' .$option . '/css/administrator/theme-dark.css', array('version' => 'auto'), [], ['template.active']);
//echo '<div style="clear:both;"></div>';
$phocaImage = ( (string)$this->element['phocaimage'] ? $this->element['phocaimage'] : '' );
$image = '';
if ($phocaImage != ''){
$image = HTMLHelper::_('image', $ti . $phocaImage, '' );
}
if ($this->element['default']) {
if ($image != '') {
return '<div class="ph-options-head">'
.'<div>'. $image.' <strong>'. Text::_($this->element['default']) . '</strong></div>'
.'</div>';
} else {
return '<div class="ph-options-head">'
.'<strong>'. Text::_($this->element['default']) . '</strong>'
.'</div>';
}
} else {
return parent::getLabel();
}
//echo '<div style="clear:both;"></div>';
}
}
?>

View File

@ -0,0 +1,51 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
jimport('joomla.html.html');
jimport('joomla.form.formfield');
class JFormFieldPhocaHeadExpert extends FormField
{
protected $type = 'PhocaHeadExpert';
protected function getLabel() { return '';}
protected function getInput() {
$tc = 'phocadownload';
$ts = 'media/com_'.$tc.'/css/administrator/';
$ti = 'media/com_'.$tc.'/images/administrator/';
HTMLHelper::stylesheet( $ts.'/'.$tc.'options.css' );
echo '<div style="clear:both;"></div>';
$phocaImage = ( (string)$this->element['phocaimage'] ? $this->element['phocaimage'] : '' );
$image = '';
if ($phocaImage != ''){
$image = HTMLHelper::_('image', $ti . $phocaImage, '' );
}
if ($this->element['default']) {
if ($image != '') {
return '<div class="ph-options-head-expert">'
.'<div>'. $image.' <strong>'. Text::_($this->element['default']) . '</strong></div>'
.'</div>';
} else {
return '<div class="ph-options-head-expert">'
.'<strong>'. Text::_($this->element['default']) . '</strong>'
.'</div>';
}
} else {
return parent::getLabel();
}
echo '<div style="clear:both;"></div>';
}
}
?>

View File

@ -0,0 +1,40 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('JPATH_BASE') or die;
jimport('joomla.form.formfield');
class JFormFieldPhocaInfoText extends JFormField
{
protected $type = 'PhocaInfoText';
protected function getInput()
{
$class = 'inputbox';
if ((string) $this->element['class'] != '') {
$class = $this->element['class'];
}
return '<div class="'.$class.'" style="padding-top:5px">'.$this->value.'</div>';
}
protected function getLabel()
{
echo '<div class="clearfix"></div>';
return parent::getLabel();
echo '<div class="clearfix"></div>';
}
}

View File

@ -0,0 +1,80 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined('JPATH_BASE') or die;
jimport('joomla.form.formfield');
class JFormFieldPhocaLongText extends JFormField
{
protected $type = 'PhocaLongText';
protected $phocaParams = null;
protected function getInput() {
$document = JFactory::getDocument();
$option = JFactory::getApplication()->input->getCmd('option');
$globalValue = $this->_getPhocaParams( $this->element['name'] );
// Initialize some field attributes.
$size = $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
$class = $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : '';
$maxLength = $this->element['maxlength'] ? ' maxlength="'.(int) $this->element['maxlength'].'"' : '';
$readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
// Initialize JavaScript field attributes.
$onchange = $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
$value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
// TODO 1.6
// MENU - Set Default value to "" because of saving "" value into the menu link ( use global = "")
if ($option == "com_menus") {
$DefaultValue = (string)$this->element['default'];
if ($value == $DefaultValue) {
$value = '';
}
}
// MENU - Display the global value
if ($option == "com_menus") {
$html ='<table><tr><td colspan="3"><input type="text" name="'.$this->name.'" id="'.$this->id.'" value="'.$value.'"'
.$class.$size.$disabled.$readonly.$onchange.$maxLength.'/></td></tr>';
$html .='<tr><td>[</td><td><input type="text" value="'. $globalValue .'" style="width:15em;border:1px solid #fff;background:#fff;" /></td><td>]</td></tr></table>';
} else {
$html ='<input type="text" name="'.$this->name.'" id="'.$this->id.'" value="'.$value.'"'
.$class.$size.$disabled.$readonly.$onchange.$maxLength.'/>';
}
return $html;
}
protected function getLabel() {
echo '<div class="clearfix"></div>';
return parent::getLabel();
echo '<div class="clearfix"></div>';
}
protected function _setPhocaParams(){
$component = 'com_phocadownload';
$paramsC = JComponentHelper::getParams($component) ;
$this->phocaParams = $paramsC;
}
protected function _getPhocaParams( $name ){
// Don't call sql query by every param item (it will be loaded only one time)
if (!$this->phocaParams) {
$params = $this->_setPhocaParams();
}
$globalValue = $this->phocaParams->get( $name, '' );
return $globalValue;
}
}
?>

View File

@ -0,0 +1,153 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
jimport('joomla.form.formfield');
class JFormFieldPhocaSelectFilename extends FormField
{
public $type = 'PhocaSelectFilename';
protected function getInput()
{
// Initialize variables.
$html = array();
$idA = 'phFileNameModal';
$onchange = (string) $this->element['onchange'];
//$size = ($v = $this->element['size']) ? ' size="' . $v . '"' : '';
//$class = ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="form-control"';
$required = ($v = $this->element['required']) ? ' required="required"' : '';
// Initialize some field attributes.
$attr = $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : 'form-control';
$attr .= $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
// Manager
$manager = $this->element['manager'] ? $this->element['manager'] : '';
$managerOutput = $this->element['manager'] ? '&amp;manager='.(string) $this->element['manager'] : '';
$idA .= 'mo' . $manager;
$group = PhocaDownloadSettings::getManagerGroup((string) $this->element['manager']);
$textButton = 'COM_PHOCADOWNLOAD_FORM_SELECT_'.strtoupper($group['t']);
$link = 'index.php?option=com_phocadownload&amp;view=phocadownloadmanager'.$group['c'].$managerOutput.'&amp;field='.$this->id;
HTMLHelper::_('jquery.framework');
$script = array();
$script[] = ' function phocaSelectFileName_'.$this->id.'(title) {';
$script[] = ' document.getElementById("'.$this->id.'").value = title;';
$script[] = ' '.$onchange;
//$script[] = ' jModalClose();';
$script[] = ' jQuery(\'#'.$idA.'\').modal(\'toggle\');';
//$script[] = ' SqueezeBox.close();';
//$script[] = ' jQuery(\'#'.$idA.'\').modal(\'toggle\');';
$script[] = ' }';
// Add the script to the document head.
Factory::getDocument()->addScriptDeclaration(implode("\n", $script));
$html[] = '<div class="input-append input-group">';
$html[] = '<span class="input-append input-group"><input type="text" id="' . $this->id . '" name="' . $this->name . '"'
. ' value="' . $this->value . '"' . $attr . ' />';
$html[] = '<a href="'.$link.'" role="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#'.$idA.'" title="' . Text::_($textButton) . '">'
. '<span class="icon-list icon-white"></span> '
. Text::_($textButton) . '</a></span>';
$html[] = '</div>'. "\n";
$html[] = HTMLHelper::_(
'bootstrap.renderModal',
$idA,
array(
'url' => $link,
'title' => Text::_($textButton),
'width' => '',
'height' => '',
'modalWidth' => '80',
'bodyHeight' => '80',
'footer' => '<div class="ph-info-modal"></div><button type="button" class="btn btn-primary" data-bs-dismiss="modal" aria-hidden="true">'
. Text::_('COM_PHOCADOWNLOAD_CLOSE') . '</button>'
)
);
return implode("\n", $html);
// Load the modal behavior script.
//JHtml::_('behavior.modal', 'a.modal_'.$this->id);
// Build the script.
/* $script = array();
$script[] = ' function phocaSelectFileName_'.$this->id.'(title) {';
$script[] = ' document.getElementById("'.$this->id.'_id").value = title;';
$script[] = ' '.$onchange;
$script[] = ' SqueezeBox.close();';
$script[] = ' }';
// Add the script to the document head.
Factory::getDocument()->addScriptDeclaration(implode("\n", $script));
*/
/*$html[] = '<div class="fltlft">';
$html[] = ' <input type="text" id="'.$this->id.'_id" name="'.$this->name.'" value="'. $this->value.'"' .
' '.$attr.' />';
$html[] = '</div>';
// Create the user select button.
$html[] = '<div class="button2-left">';
$html[] = ' <div class="blank">';
$html[] = ' <a class="modal_'.$this->id.'" title="'.Text::_($textButton).'"' .
' href="'.($this->element['readonly'] ? '' : $link).'"' .
' rel="{handler: \'iframe\', size: {x: 780, y: 560}}">';
$html[] = ' '.Text::_($textButton).'</a>';
$html[] = ' </div>';
$html[] = '</div>';*/
/* Factory::getDocument()->addScriptDeclaration('
function phocaSelectFileName_' . $this->id . '(name) {
document.getElementById("' . $this->id . '").value = name;
jQuery(\'#'.$idA.'\').modal(\'toggle\');
}
');*/
/*$html[] = '<span class="input-append"><input type="text" ' . $required . ' id="' . $this->id . '" name="' . $this->name . '"'
. ' value="' . $this->value . '"' . $size . $class . ' />';
$html[] = '<a href="#'.$idA.'" role="button" class="btn btn-primary" data-toggle="modal" title="' . Text::_($textButton) . '">'
. '<span class="icon-list icon-white"></span> '
. Text::_($textButton) . '</a></span>';
$html[] = HTMLHelper::_(
'bootstrap.renderModal',
$idA,
array(
'url' => $link,
'title' => Text::_($textButton),
'width' => '700px',
'height' => '400px',
'modalWidth' => '80',
'bodyHeight' => '70',
'footer' => '<button type="button" class="btn btn-primary" data-bs-dismiss="modal" aria-hidden="true">'
. Text::_('COM_PHOCADOWNLOAD_CLOSE') . '</button>'
)
);*/
}
}

View File

@ -0,0 +1,41 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined('_JEXEC') or die();
use Joomla\CMS\Form\FormField;
class JFormFieldPhocaTags extends FormField
{
protected $type = 'PhocaTags';
protected function getInput() {
$id = (int) $this->form->getValue('id');
$activeTags = array();
if ((int)$id > 0) {
$activeTags = PhocaDownloadTag::getTags($id, 1);
}
//return PhocaGalleryTag::getAllTagsSelectBox($this->name, $this->id, $activeTags, NULL,'id' );
$tags = PhocaDownloadTag::getAllTags();
$data = $this->getLayoutData();
$data['options'] = (array)$tags;
$data['value'] = $activeTags;
return $this->getRenderer($this->layout)->render($data);
}
}
?>

View File

@ -0,0 +1,75 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('JPATH_BASE') or die;
jimport('joomla.form.formfield');
class JFormFieldPhocaText extends JFormField
{
protected $type = 'PhocaText';
protected $phocaParams = null;
protected function getInput() {
$document = JFactory::getDocument();
$option = JFactory::getApplication()->input->getCmd('option');
$globalValue = $this->_getPhocaParams( $this->element['name'] );
// Initialize some field attributes.
$size = $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
$class = $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : '';
$maxLength = $this->element['maxlength'] ? ' maxlength="'.(int) $this->element['maxlength'].'"' : '';
$readonly = ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
// Initialize JavaScript field attributes.
$onchange = $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
$value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
// TODO 1.6
// MENU - Set Default value to "" because of saving "" value into the menu link ( use global = "")
if ($option == "com_menus") {
$DefaultValue = (string)$this->element['default'];
if ($value == $DefaultValue) {
$value = '';
}
}
$html ='<input type="text" name="'.$this->name.'" id="'.$this->id.'" value="'.$value.'"'
.$class.$size.$disabled.$readonly.$onchange.$maxLength.'/>';
// MENU - Display the global value
if ($option == "com_menus") {
$html .= '<span style="margin-left:10px;">[</span><span style="background:#fff;"> ' . $globalValue . ' </span><span>]</span>';
}
return $html;
}
protected function getLabel() {
echo '<div class="clearfix"></div>';
return parent::getLabel();
echo '<div class="clearfix"></div>';
}
protected function _setPhocaParams(){
$component = 'com_phocadownload';
$paramsC = JComponentHelper::getParams($component) ;
$this->phocaParams = $paramsC;
}
protected function _getPhocaParams( $name ){
// Don't call sql query by every param item (it will be loaded only one time)
if (!$this->phocaParams) {
$params = $this->_setPhocaParams();
}
$globalValue = $this->phocaParams->get( $name, '' );
return $globalValue;
}
}
?>

View File

@ -0,0 +1,81 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('JPATH_BASE') or die;
jimport('joomla.form.formfield');
class JFormFieldPhocaTextArea extends JFormField
{
protected $type = 'PhocaTextArea';
protected $phocaParams = null;
protected function getInput() {
$document = JFactory::getDocument();
$option = JFactory::getApplication()->input->getCmd('option');
$globalValue = $this->_getPhocaParams( $this->element['name'] );
// Initialize some field attributes.
$class = $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : '';
$disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
$columns = $this->element['cols'] ? ' cols="'.(int) $this->element['cols'].'"' : '';
$rows = $this->element['rows'] ? ' rows="'.(int) $this->element['rows'].'"' : '';
// Initialize JavaScript field attributes.
$onchange = $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
$value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
// TODO 1.6
// MENU - Set Default value to "" because of saving "" value into the menu link ( use global = "")
if ($option == "com_menus") {
$DefaultValue = (string)$this->element['default'];
if ($value == $DefaultValue) {
$value = '';
}
}
// MENU - Display the global value
if ($option == "com_menus") {
$html ='<table><tr><td colspan="3"><textarea name="'.$this->name.'" id="'.$this->id.'"' .
$columns.$rows.$class.$disabled.$onchange.'>' .
$value .
'</textarea></td></tr>';
$html .='<tr><td>[</td><td><input type="text" value="'. $globalValue .'" style="width:15em;border:1px solid #fff;background:#fff;" /></td><td>]</td></tr></table>';
} else {
$html = '<textarea name="'.$this->name.'" id="'.$this->id.'"' .
$columns.$rows.$class.$disabled.$onchange.'>' .
$value .
'</textarea>';
}
return $html;
}
protected function getLabel() {
echo '<div class="clearfix"></div>';
return parent::getLabel();
echo '<div class="clearfix"></div>';
}
protected function _setPhocaParams(){
$component = 'com_phocadownload';
$paramsC = JComponentHelper::getParams($component) ;
$this->phocaParams = $paramsC;
}
protected function _getPhocaParams( $name ){
// Don't call sql query by every param item (it will be loaded only one time)
if (!$this->phocaParams) {
$params = $this->_setPhocaParams();
}
$globalValue = $this->phocaParams->get( $name, '' );
return $globalValue;
}
}
?>

View File

@ -0,0 +1,46 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined('_JEXEC') or die();
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Form\Field\ListField;
phocadownloadimport('phocadownload.user.user');
class JFormFieldPhocaUsers extends ListField
{
protected $type = 'PhocaUsers';
protected function getInput() {
$data = $this->getLayoutData();
$userId = (string) $this->form->getValue($this->element['name']);
$data['options'] = (array) PhocaDownloadUser::usersList($this->name, $this->id, $userId, 1, NULL,'name', 0, 1 );
$activeArray = $userId;
if ($userId != '') {
$activeArray = explode(',',$userId);
}
if (!empty($activeArray)) {
$data['value'] = $activeArray;
} else {
$data['value'] = $this->value;
}
return $this->getRenderer($this->layout)->render($data);
}
}
?>

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<fields name="filter">
<field name="search" type="text" inputmode="search" label="COM_PHOCADOWNLOAD_SEARCH" description="COM_PHOCADOWNLOAD_SEARCH" hint="JSEARCH_FILTER" />
<field name="published" type="list" label="JOPTION_FILTER_PUBLISHED" description="JOPTION_FILTER_PUBLISHED_DESC" onchange="this.form.submit();" >
<option value="">JOPTION_SELECT_PUBLISHED</option>
<option value="1">COM_PHOCADOWNLOAD_PUBLISHED</option>
<option value="0">COM_PHOCADOWNLOAD_UNPUBLISHED</option>
</field>
<field name="level" type="list" label="JOPTION_FILTER_PUBLISHED" description="JOPTION_FILTER_PUBLISHED_DESC" onchange="this.form.submit();" >
<option value="">COM_PHOCADOWNLOAD_SELECT_MAX_LEVELS_HEAD</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</field>
<field name="language" type="contentlanguage" label="JOPTION_FILTER_LANGUAGE" description="JOPTION_FILTER_LANGUAGE_DESC" onchange="this.form.submit();">
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
<input type="hidden" name="form_submited" value="1"/>
</fields>
<fields name="list">
<field name="fullordering" type="list" label="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING" description="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING_DESC" onchange="this.form.submit();" default="a.ordering ASC" validate="options" >
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.published ASC" >COM_PHOCADOWNLOAD_PUBLISHED_ASC</option>
<option value="a.published DESC" >COM_PHOCADOWNLOAD_PUBLISHED_DESC</option>
<option value="parentcat_title ASC">COM_PHOCADOWNLOAD_PARENT_CATEGORY_ASC</option>
<option value="parentcat_title DESC">COM_PHOCADOWNLOAD_PARENT_CATEGORY_DESC</option>
<option value="a.language ASC">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="a.language DESC">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field name="limit" type="limitbox" label="COM_PHOCADOWNLOAD_LIST_LIMIT" description="COM_PHOCADOWNLOAD_LIST_LIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" />
</fields>
</fieldset>
</form>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<fields name="filter">
<field name="search" type="text" inputmode="search" label="COM_PHOCADOWNLOAD_SEARCH" description="COM_PHOCADOWNLOAD_SEARCH" hint="JSEARCH_FILTER" />
<input type="hidden" name="form_submited" value="1"/>
</fields>
<fields name="list">
<field name="fullordering" type="list" label="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING" description="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING_DESC" onchange="this.form.submit();" default="username ASC" validate="options" >
<option value="">JGLOBAL_SORT_BY</option>
<option value="username ASC">COM_PHOCADOWNLOAD_USER_ASC</option>
<option value="username DESC">COM_PHOCADOWNLOAD_USER_DESC</option>
<option value="a.count ASC">COM_PHOCADOWNLOAD_COUNT_ASC</option>
<option value="a.count DESC">COM_PHOCADOWNLOAD_COUNT_DESC</option>
<option value="filename ASC">COM_PHOCADOWNLOAD_FILENAME_ASC</option>
<option value="filename DESC">COM_PHOCADOWNLOAD_FILENAME_DESC</option>
</field>
<field name="limit" type="limitbox" label="COM_PHOCADOWNLOAD_LIST_LIMIT" description="COM_PHOCADOWNLOAD_LIST_LIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" />
</fields>
</fieldset>
</form>

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<fields name="filter">
<field name="search" type="text" inputmode="search" label="COM_PHOCADOWNLOAD_SEARCH" description="COM_PHOCADOWNLOAD_SEARCH" hint="JSEARCH_FILTER" />
<field name="published" type="list" label="JOPTION_FILTER_PUBLISHED" description="JOPTION_FILTER_PUBLISHED_DESC" onchange="this.form.submit();" >
<option value="">JOPTION_SELECT_PUBLISHED</option>
<option value="1">COM_PHOCADOWNLOAD_PUBLISHED</option>
<option value="0">COM_PHOCADOWNLOAD_UNPUBLISHED</option>
</field>
<!--<field name="category_id" type="PhocaDownloadCategory" label="JOPTION_FILTER_CATEGORY" description="JOPTION_FILTER_CATEGORY_DESC" onchange="this.form.submit();" />-->
<field name="category_id" type="PhocaDownloadCategory" typemethod="filter" layout="joomla.form.field.list-fancy-select" label="JOPTION_FILTER_CATEGORY" description="JOPTION_FILTER_CATEGORY_DESC" onchange="this.form.submit();" class="js-select-submit-on-change" multiple="true" hint="JOPTION_SELECT_CATEGORY" />
<field name="language" type="contentlanguage" label="JOPTION_FILTER_LANGUAGE" description="JOPTION_FILTER_LANGUAGE_DESC" onchange="this.form.submit();">
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>
<input type="hidden" name="form_submited" value="1"/>
</fields>
<fields name="list">
<field name="fullordering" type="list" label="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING" description="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING_DESC" onchange="this.form.submit();" default="a.id DESC" validate="options" >
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.filename ASC">COM_PHOCADOWNLOAD_FILENAME_ASC</option>
<option value="a.filename DESC">COM_PHOCADOWNLOAD_FILENAME_DESC</option>
<option value="a.published ASC" >COM_PHOCADOWNLOAD_PUBLISHED_ASC</option>
<option value="a.published DESC" >COM_PHOCADOWNLOAD_PUBLISHED_DESC</option>
<option value="a.approved ASC" >COM_PHOCADOWNLOAD_APPROVED_ASC</option>
<option value="a.approved DESC" >COM_PHOCADOWNLOAD_APPROVED_DESC</option>
<option value="category_id ASC">JCATEGORY_ASC</option>
<option value="category_id DESC">JCATEGORY_DESC</option>
<option value="uploadusername ASC">COM_PHOCADOWNLOAD_UPLOADED_BY_ASC</option>
<option value="uploadusername DESC">COM_PHOCADOWNLOAD_UPLOADED_BY_DESC</option>
<option value="a.owner_id ASC">COM_PHOCADOWNLOAD_OWNER_ASC</option>
<option value="a.owner_id DESC">COM_PHOCADOWNLOAD_OWNER_DESC</option>
<option value="a.hits ASC">COM_PHOCADOWNLOAD_DOWNLOADS_ASC</option>
<option value="a.hits DESC">COM_PHOCADOWNLOAD_DOWNLOADS_DESC</option>
<option value="a.date ASC">COM_PHOCADOWNLOAD_DATE_ASC</option>
<option value="a.date DESC">COM_PHOCADOWNLOAD_DATE_DESC</option>
<option value="a.language ASC">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="a.language DESC">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field name="limit" type="limitbox" label="COM_PHOCADOWNLOAD_LIST_LIMIT" description="COM_PHOCADOWNLOAD_LIST_LIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" />
</fields>
</fieldset>
</form>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<fields name="filter">
<field name="search" type="text" inputmode="search" label="COM_PHOCADOWNLOAD_SEARCH" description="COM_PHOCADOWNLOAD_SEARCH" hint="JSEARCH_FILTER" />
<field name="published" type="list" label="JOPTION_FILTER_PUBLISHED" description="JOPTION_FILTER_PUBLISHED_DESC" onchange="this.form.submit();" >
<option value="">JOPTION_SELECT_PUBLISHED</option>
<option value="1">COM_PHOCADOWNLOAD_PUBLISHED</option>
<option value="0">COM_PHOCADOWNLOAD_UNPUBLISHED</option>
</field>
<input type="hidden" name="form_submited" value="1"/>
</fields>
<fields name="list">
<field name="fullordering" type="list" label="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING" description="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING_DESC" onchange="this.form.submit();" default="a.title ASC" validate="options" >
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.published ASC" >COM_PHOCADOWNLOAD_PUBLISHED_ASC</option>
<option value="a.published DESC" >COM_PHOCADOWNLOAD_PUBLISHED_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field name="limit" type="limitbox" label="COM_PHOCADOWNLOAD_LIST_LIMIT" description="COM_PHOCADOWNLOAD_LIST_LIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" />
</fields>
</fieldset>
</form>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<fields name="filter">
<field name="search" type="text" inputmode="search" label="COM_PHOCADOWNLOAD_SEARCH" description="COM_PHOCADOWNLOAD_SEARCH" hint="JSEARCH_FILTER" />
<field name="type" type="list" label="JOPTION_FILTER_PUBLISHED" description="JOPTION_FILTER_PUBLISHED_DESC" onchange="this.form.submit();" >
<option value="">COM_PHOCADOWNLOAD_FILTER_SELECT_TYPE_HEAD</option>
<option value="1">COM_PHOCADOWNLOAD_DOWNLOADS</option>
<option value="2">COM_PHOCADOWNLOAD_UPLOADS</option>
</field>
<input type="hidden" name="form_submited" value="1"/>
</fields>
<fields name="list">
<field name="fullordering" type="list" label="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING" description="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING_DESC" onchange="this.form.submit();" default="username ASC" validate="options" >
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.date ASC">COM_PHOCADOWNLOAD_DATE_ASC</option>
<option value="a.date DESC">COM_PHOCADOWNLOAD_DATE_DESC</option>
<option value="username ASC">COM_PHOCADOWNLOAD_USER_ASC</option>
<option value="username DESC">COM_PHOCADOWNLOAD_USER_DESC</option>
<option value="d.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="d.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="filename ASC">COM_PHOCADOWNLOAD_FILENAME_ASC</option>
<option value="filename DESC">COM_PHOCADOWNLOAD_FILENAME_DESC</option>
<option value="category_id ASC">JCATEGORY_ASC</option>
<option value="category_id DESC">JCATEGORY_DESC</option>
<option value="a.ip ASC">COM_PHOCADOWNLOAD_IP_ASC</option>
<option value="a.ip DESC">COM_PHOCADOWNLOAD_IP_DESC</option>
<option value="a.page ASC">COM_PHOCADOWNLOAD_PAGE_ASC</option>
<option value="a.page DESC">COM_PHOCADOWNLOAD_PAGE_DESC</option>
<option value="a.type ASC">COM_PHOCADOWNLOAD_TYPE_ASC</option>
<option value="a.type DESC">COM_PHOCADOWNLOAD_TYPE_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field name="limit" type="limitbox" label="COM_PHOCADOWNLOAD_LIST_LIMIT" description="COM_PHOCADOWNLOAD_LIST_LIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" />
</fields>
</fieldset>
</form>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<fields name="filter">
<field name="search" type="text" inputmode="search" label="COM_PHOCADOWNLOAD_SEARCH" description="COM_PHOCADOWNLOAD_SEARCH" hint="JSEARCH_FILTER" />
<!--<field name="published" type="list" label="JOPTION_FILTER_PUBLISHED" description="JOPTION_FILTER_PUBLISHED_DESC" onchange="this.form.submit();" >
<option value="">JOPTION_SELECT_PUBLISHED</option>
<option value="1">COM_PHOCADOWNLOAD_PUBLISHED</option>
<option value="0">COM_PHOCADOWNLOAD_UNPUBLISHED</option>
</field> -->
<field name="category_id" type="PhocaDownloadCategory" label="JOPTION_FILTER_CATEGORY" description="JOPTION_FILTER_CATEGORY_DESC" onchange="this.form.submit();" />
<!--
<field name="language" type="contentlanguage" label="JOPTION_FILTER_LANGUAGE" description="JOPTION_FILTER_LANGUAGE_DESC" onchange="this.form.submit();">
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field> -->
<input type="hidden" name="form_submited" value="1"/>
</fields>
<fields name="list">
<field name="fullordering" type="list" label="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING" description="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING_DESC" onchange="this.form.submit();" default="ua.username ASC" validate="options" >
<option value="">JGLOBAL_SORT_BY</option>
<option value="category_title ASC">COM_PHOCADOWNLOAD_CATEGORY_ASC</option>
<option value="category_title DESC">COM_PHOCADOWNLOAD_CATEGORY_DESC</option>
<option value="file_title ASC">COM_PHOCADOWNLOAD_FILENAME_ASC</option>
<option value="file_title DESC">COM_PHOCADOWNLOAD_FILENAME_DESC</option>
<option value="ua.username ASC">COM_PHOCADOWNLOAD_USER_ASC</option>
<option value="ua.username DESC">COM_PHOCADOWNLOAD_USER_DESC</option>
<option value="a.rating ASC">COM_PHOCADOWNLOAD_RATING_ASC</option>
<option value="a.rating DESC">COM_PHOCADOWNLOAD_RATING_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field name="limit" type="limitbox" label="COM_PHOCADOWNLOAD_LIST_LIMIT" description="COM_PHOCADOWNLOAD_LIST_LIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" />
</fields>
</fieldset>
</form>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<fields name="filter">
<field name="search" type="text" inputmode="search" label="COM_PHOCADOWNLOAD_SEARCH" description="COM_PHOCADOWNLOAD_SEARCH" hint="JSEARCH_FILTER" />
<!--<field name="published" type="list" label="JOPTION_FILTER_PUBLISHED" description="JOPTION_FILTER_PUBLISHED_DESC" onchange="this.form.submit();" >
<option value="">JOPTION_SELECT_PUBLISHED</option>
<option value="1">COM_PHOCADOWNLOAD_PUBLISHED</option>
<option value="0">COM_PHOCADOWNLOAD_UNPUBLISHED</option>
</field>-->
<input type="hidden" name="form_submited" value="1"/>
</fields>
<fields name="list">
<field name="fullordering" type="list" label="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING" description="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING_DESC" onchange="this.form.submit();" default="a.title ASC" validate="options" >
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.filename ASC">COM_PHOCADOWNLOAD_FILENAME_ASC</option>
<option value="a.filename DESC">COM_PHOCADOWNLOAD_FILENAME_DESC</option>
<option value="a.hits ASC">COM_PHOCADOWNLOAD_DOWNLOADS_ASC</option>
<option value="a.hits DESC">COM_PHOCADOWNLOAD_DOWNLOADS_DESC</option>
</field>
<field name="limit" type="limitbox" label="COM_PHOCADOWNLOAD_LIST_LIMIT" description="COM_PHOCADOWNLOAD_LIST_LIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" />
</fields>
</fieldset>
</form>

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<fields name="filter">
<field name="search" type="text" inputmode="search" label="COM_PHOCADOWNLOAD_SEARCH" description="COM_PHOCADOWNLOAD_SEARCH" hint="JSEARCH_FILTER" />
<field name="published" type="list" label="JOPTION_FILTER_PUBLISHED" description="JOPTION_FILTER_PUBLISHED_DESC" onchange="this.form.submit();" >
<option value="">JOPTION_SELECT_PUBLISHED</option>
<option value="1">COM_PHOCADOWNLOAD_PUBLISHED</option>
<option value="0">COM_PHOCADOWNLOAD_UNPUBLISHED</option>
</field>
<field name="category_id" type="list" label="JOPTION_FILTER_PUBLISHED" description="JOPTION_FILTER_PUBLISHED_DESC" onchange="this.form.submit();" >
<option value="">COM_PHOCADOWNLOAD_FILTER_SELECT_TYPE_HEAD</option>
<option value="1">COM_PHOCADOWNLOAD_MAIN_CSS</option>
<option value="2">COM_PHOCADOWNLOAD_CUSTOM_CSS</option>
</field>
<!--<field name="language" type="contentlanguage" label="JOPTION_FILTER_LANGUAGE" description="JOPTION_FILTER_LANGUAGE_DESC" onchange="this.form.submit();">
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field>-->
<input type="hidden" name="form_submited" value="1"/>
</fields>
<fields name="list">
<field name="fullordering" type="list" label="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING" description="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING_DESC" onchange="this.form.submit();" default="a.title ASC" validate="options" >
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.filename ASC">COM_PHOCADOWNLOAD_FILENAME_ASC</option>
<option value="a.filename DESC">COM_PHOCADOWNLOAD_FILENAME_DESC</option>
<option value="a.published ASC" >COM_PHOCADOWNLOAD_PUBLISHED_ASC</option>
<option value="a.published DESC" >COM_PHOCADOWNLOAD_PUBLISHED_DESC</option>
<option value="a.type ASC" >COM_PHOCADOWNLOAD_TYPE_ASC</option>
<option value="a.type DESC" >COM_PHOCADOWNLOAD_TYPE_DESC</option>
<option value="a.language ASC">JGRID_HEADING_LANGUAGE_ASC</option>
<option value="a.language DESC">JGRID_HEADING_LANGUAGE_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field name="limit" type="limitbox" label="COM_PHOCADOWNLOAD_LIST_LIMIT" description="COM_PHOCADOWNLOAD_LIST_LIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" />
</fields>
</fieldset>
</form>

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<fields name="filter">
<field name="search" type="text" inputmode="search" label="COM_PHOCADOWNLOAD_SEARCH" description="COM_PHOCADOWNLOAD_SEARCH" hint="JSEARCH_FILTER" />
<field name="published" type="list" label="JOPTION_FILTER_PUBLISHED" description="JOPTION_FILTER_PUBLISHED_DESC" onchange="this.form.submit();" >
<option value="">JOPTION_SELECT_PUBLISHED</option>
<option value="1">COM_PHOCADOWNLOAD_PUBLISHED</option>
<option value="0">COM_PHOCADOWNLOAD_UNPUBLISHED</option>
</field>
<!--
<field name="language" type="contentlanguage" label="JOPTION_FILTER_LANGUAGE" description="JOPTION_FILTER_LANGUAGE_DESC" onchange="this.form.submit();">
<option value="">JOPTION_SELECT_LANGUAGE</option>
<option value="*">JALL</option>
</field> -->
<input type="hidden" name="form_submited" value="1"/>
</fields>
<fields name="list">
<field name="fullordering" type="list" label="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING" description="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING_DESC" onchange="this.form.submit();" default="a.title ASC" validate="options" >
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.published ASC" >COM_PHOCADOWNLOAD_PUBLISHED_ASC</option>
<option value="a.published DESC" >COM_PHOCADOWNLOAD_PUBLISHED_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field name="limit" type="limitbox" label="COM_PHOCADOWNLOAD_LIST_LIMIT" description="COM_PHOCADOWNLOAD_LIST_LIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" />
</fields>
</fieldset>
</form>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<fields name="filter">
<field name="search" type="text" inputmode="search" label="COM_PHOCADOWNLOAD_SEARCH" description="COM_PHOCADOWNLOAD_SEARCH" hint="JSEARCH_FILTER" />
<input type="hidden" name="form_submited" value="1"/>
</fields>
<fields name="list">
<field name="fullordering" type="list" label="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING" description="COM_PHOCADOWNLOAD_LIST_FULL_ORDERING_DESC" onchange="this.form.submit();" default="username ASC" validate="options" >
<option value="">JGLOBAL_SORT_BY</option>
<!--<option value="d.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="d.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="d.filename ASC">COM_PHOCADOWNLOAD_FILENAME_ASC</option>
<option value="d.filename DESC">COM_PHOCADOWNLOAD_FILENAME_DESC</option>
<option value="a.count ASC">COM_PHOCADOWNLOAD_COUNT_ASC</option>
<option value="a.count DESC">COM_PHOCADOWNLOAD_COUNT_DESC</option>-->
<option value="username ASC">COM_PHOCADOWNLOAD_USER_ASC</option>
<option value="username DESC">COM_PHOCADOWNLOAD_USER_DESC</option>
</field>
<field name="limit" type="limitbox" label="COM_PHOCADOWNLOAD_LIST_LIMIT" description="COM_PHOCADOWNLOAD_LIST_LIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" />
</fields>
</fieldset>
</form>

View File

@ -0,0 +1 @@
<html><body></body></html>

View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<field name="id" type="text" default="0" label="JGLOBAL_FIELD_ID_LABEL" required="true" readonly="true" class="readonly" />
<field name="title" type="text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_FIELD_TITLE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_TITLE_DESC" required="true" />
<field name="alias" type="text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_FIELD_ALIAS_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ALIAS_DESC" />
<field name="project_name" type="text" class="form-control" size="128" label="COM_PHOCADOWNLOAD_FIELD_PROJECT_NAME_LABEL" description="COM_PHOCADOWNLOAD_FIELD_PROJECT_NAME_DESC" />
<field name="parent_id" type="phocadownloadcategory" label="COM_PHOCADOWNLOAD_FIELD_PARENT_CATEGORY_LABEL" description="COM_PHOCADOWNLOAD_FIELD_PARENT_CATEGORY_DESC" />
<field name="ordering" type="PhocaDownloadOrdering" table="category" class="form-select" label="COM_PHOCADOWNLOAD_FIELD_ORDERING_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ORDERING_DESC" />
<field name="access" type="accesslevel" label="JFIELD_ACCESS_LABEL" description="JFIELD_ACCESS_DESC" class="form-select" size="1" />
<field name="accessuserid" type="phocausers" multiple="true" label="COM_PHOCADOWNLOAD_FIELD_ACCESS_RIGHTS_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ACCESS_RIGHTS_DESC" size="1" layout="joomla.form.field.list-fancy-select" />
<field name="uploaduserid" type="phocausers" multiple="true" label="COM_PHOCADOWNLOAD_FIELD_UPLOAD_RIGHTS_LABEL" description="COM_PHOCADOWNLOAD_FIELD_UPLOAD_RIGHTS_DESC" size="1" layout="joomla.form.field.list-fancy-select" />
<field name="deleteuserid" type="phocausers" multiple="true" label="COM_PHOCADOWNLOAD_FIELD_DELETE_RIGHTS_LABEL" description="COM_PHOCADOWNLOAD_FIELD_DELETE_RIGHTS_DESC" size="1" layout="joomla.form.field.list-fancy-select" />
<field name="image" type="phocaselectfilename" manager="image" label="COM_PHOCADOWNLOAD_FIELD_CATEGORY_IMAGE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_CATEGORY_IMAGE_DESC" class="form-control" size="40" />
<field name="description" type="editor" buttons="true" hide="pagebreak,readmore" class="form-control" label="COM_PHOCADOWNLOAD_FIELD_DESCRIPTION_LABEL" filter="\Joomla\CMS\Component\ComponentHelper::filterText" description="COM_PHOCADOWNLOAD_FIELD_DESCRIPTION_DESC" />
<field name="metakey" type="textarea"
label="JField_Meta_Keywords_Label" description="JField_Meta_Keywords_Desc"
class="form-control" rows="3" cols="30" />
<field name="metadesc" type="textarea"
label="JField_Meta_Description_Label" description="JField_Meta_Description_Desc"
class="form-control" rows="3" cols="30" />
</fieldset>
<fieldset name="publish" label="COM_PHOCADOWNLOAD_GROUP_LABEL_PUBLISHING_DETAILS" >
<field name="published" type="list" label="COM_PHOCADOWNLOAD_FIELD_PUBLISHED_LABEL" description="COM_PHOCADOWNLOAD_FIELD_PUBLISHED_DESC" class="form-select" size="1" default="1">
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
<field name="language" type="contentlanguage" label="JFIELD_LANGUAGE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_LANGUAGE_CATEGORY_DESC" class="form-select">
<option value="*">JALL</option>
</field>
<field name="date" type="Calendar" class="form-control" label="COM_PHOCADOWNLOAD_FIELD_DATE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_DATE_DESC" showtime="true" filter="user_utc" translateformat="true" />
<!--
<field name="hits" type="Text" class="form-control" size="6" label="COM_PHOCADOWNLOAD_FIELD_HITS" description="COM_PHOCADOWNLOAD_FIELD_HITS_DESC" />
-->
</fieldset>
<fields name="metadata">
<fieldset name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<!--
<field name="robots" type="list"
label="JField_Metadata_Robots_Label" description="JField_Metadata_Robots_Desc"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JGLOBAL_INDEX_FOLLOW</option>
<option value="1">JGLOBAL_NOINDEX_FOLLOW</option>
<option value="2">JGLOBAL_INDEX_NOFOLLOW</option>
<option value="3">JGLOBAL_NOINDEX_NOFOLLOW</option>
<option value="4">JGLOBAL_NO_ROBOTS_TAG</option>
</field>
<field name="author" type="text" label="JAUTHOR"
description="JField_Metadata_Author_Desc" size="20" />
<field name="rights" type="text"
label="JFIELD_META_RIGHTS_LABEL" description="JFIELD_META_RIGHTS_DESC"
required="" filter="string" cols="30" rows="2" /> -->
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,161 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<field name="id" type="text" default="0" label="JGLOBAL_FIELD_ID_LABEL" required="true" readonly="true" class="readonly" />
<field name="textonly" type="hidden" default="0" label="COM_PHOCADOWNLOAD_FIELD_TEXTONLY_LABEL" readonly="true" class="readonly" />
<field name="title" type="text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_FIELD_TITLE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_TITLE_DESC" />
<field name="alias" type="text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_FIELD_ALIAS_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ALIAS_DESC" />
<field name="project_name" type="text" class="form-control" size="128" label="COM_PHOCADOWNLOAD_FIELD_PROJECT_NAME_LABEL" description="COM_PHOCADOWNLOAD_FIELD_PROJECT_NAME_DESC" />
<field name="catid" type="phocadownloadcategory" onchange="changeCatid()" label="COM_PHOCADOWNLOAD_FIELD_CATEGORY_LABEL" description="COM_PHOCADOWNLOAD_FIELD_CATEGORY_DESC" required="true" />
<field name="ordering" type="PhocaDownloadOrdering" table="file" class="form-select" label="COM_PHOCADOWNLOAD_FIELD_ORDERING_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ORDERING_DESC" />
<field name="filename" type="phocaselectfilename" manager="file" label="COM_PHOCADOWNLOAD_FIELD_FILENAME_LABEL" required="true" description="COM_PHOCADOWNLOAD_FIELD_FILENAME_DESC" class="form-control" size="40" />
<field name="filename_play" type="phocaselectfilename" manager="fileplay" label="COM_PHOCADOWNLOAD_FIELD_FILEPLAY_LABEL" description="COM_PHOCADOWNLOAD_FIELD_FILEPLAY_DESC" class="form-control" size="40" />
<field name="filename_preview" type="phocaselectfilename" manager="filepreview" label="COM_PHOCADOWNLOAD_FIELD_FILEPREVIEW_LABEL" description="COM_PHOCADOWNLOAD_FIELD_FILEPREVIEW_DESC" class="form-control" size="40" />
<field name="image_filename" type="phocaselectfilename" manager="icon" label="COM_PHOCADOWNLOAD_FIELD_ICON_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ICON_DESC" class="form-control" size="40" />
<field name="image_filename_spec1" type="phocaselectfilename" manager="iconspec1" label="COM_PHOCADOWNLOAD_FIELD_ICON_SPEC1_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ICON_SPEC1_DESC" class="form-control" size="40" />
<field name="image_filename_spec2" type="phocaselectfilename" manager="iconspec2" label="COM_PHOCADOWNLOAD_FIELD_ICON_SPEC2_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ICON_SPEC2_DESC" class="form-control" size="40" />
<field name="image_download" type="phocaselectfilename" manager="image" label="COM_PHOCADOWNLOAD_FIELD_IMAGE_DOWNLOAD_LABEL" description="COM_PHOCADOWNLOAD_FIELD_IMAGE_DOWNLOAD_DESC" class="form-control" size="40" />
<field name="version" type="text" label="COM_PHOCADOWNLOAD_FIELD_VERSION_LABEL" description="COM_PHOCADOWNLOAD_FIELD_VERSION_DESC" class="form-control" size="40" />
<field name="author_url" type="text" label="COM_PHOCADOWNLOAD_FIELD_AUTHOR_URL_LABEL" description="COM_PHOCADOWNLOAD_FIELD_AUTHOR_URL_DESC" class="form-control" size="40" />
<field name="author" type="text" label="COM_PHOCADOWNLOAD_FIELD_AUTHOR_LABEL" description="COM_PHOCADOWNLOAD_FIELD_AUTHOR_DESC" class="form-control" size="40" />
<field name="author_email" type="text" label="COM_PHOCADOWNLOAD_FIELD_AUTHOR_EMAIL_LABEL" description="COM_PHOCADOWNLOAD_FIELD_AUTHOR_EMAIL_DESC" class="form-control" size="40" />
<field name="license" type="text" label="COM_PHOCADOWNLOAD_FIELD_LICENSE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_LICENSE_DESC" class="form-control" size="40" />
<field name="license_url" type="text" label="COM_PHOCADOWNLOAD_FIELD_LICENSE_URL_LABEL" description="COM_PHOCADOWNLOAD_FIELD_LICENSE_URL_DESC" class="form-control" size="40" />
<field name="confirm_license" type="phocadownloadlicense" label="COM_PHOCADOWNLOAD_FIELD_CONFIRM_LICENSE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_CONFIRM_LICENSE_DESC" class="form-control" size="40" />
<field name="directlink" type="list" label="COM_PHOCADOWNLOAD_FIELD_DIRECT_LINK_LABEL" default="0" description="COM_PHOCADOWNLOAD_FIELD_DIRECT_LINK_DESC" class="form-select" >
<option value="1">COM_PHOCADOWNLOAD_YES</option>
<option value="0">COM_PHOCADOWNLOAD_NO</option>
</field>
<field name="link_external" type="text" label="COM_PHOCADOWNLOAD_FIELD_EXTERNAL_LINK_LABEL" description="COM_PHOCADOWNLOAD_FIELD_EXTERNAL_LINK_DESC" class="form-control" size="40" />
<field name="access" type="accesslevel" label="JFIELD_ACCESS_LABEL" description="JFIELD_ACCESS_DESC" class="form-select" size="1" />
<field name="unaccessible_file" type="list" label="COM_PHOCADOWNLOAD_FIELD_DISPLAY_INACCESSIBLE_FILE_LABEL" default="0" description="COM_PHOCADOWNLOAD_FIELD_DISPLAY_INACCESSIBLE_FILE_DESC" class="form-select" >
<option value="1">COM_PHOCADOWNLOAD_YES</option>
<option value="0">COM_PHOCADOWNLOAD_NO</option>
</field>
<field name="userid" type="user" section="com_phocadownload" default="" label="COM_PHOCADOWNLOAD_FIELD_UPLOADED_BY_LABEL" description="COM_PHOCADOWNLOAD_FIELD_UPLOADED_BY_DESC"/>
<field name="owner_id" type="user" section="com_phocadownload" default="" label="COM_PHOCADOWNLOAD_FIELD_OWNER_LABEL" description="COM_PHOCADOWNLOAD_FIELD_OWNER_DESC"/>
<field name="mirror1link" type="Text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_MIRROR_LINK_LINK_LABEL" description="COM_PHOCADOWNLOAD_FIELD_MIRROR_LINK_LINK_DESC" />
<field name="mirror1title" type="Text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_MIRROR_LINK_TITLE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_MIRROR_LINK_TITLE_DESC" />
<field name="mirror1target" type="list" class="form-select" label="COM_PHOCADOWNLOAD_MIRROR_LINK_TARGET_LABEL" description="COM_PHOCADOWNLOAD_FIELD_MIRROR_LINK_TARGET_DESC" default="_self" >
<option value="_self">COM_PHOCADOWNLOAD_OPEN_WINDOW_SELF</option>
<option value="_blank">COM_PHOCADOWNLOAD_OPEN_WINDOW_BLANK</option>
<option value="_parent">COM_PHOCADOWNLOAD_OPEN_WINDOW_PARENT</option>
<option value="_top">COM_PHOCADOWNLOAD_OPEN_WINDOW_TOP</option>
</field>
<field name="mirror2link" type="Text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_MIRROR_LINK_LINK2_LABEL" description="COM_PHOCADOWNLOAD_FIELD_MIRROR_LINK_LINK2_DESC" />
<field name="mirror2title" type="Text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_MIRROR_LINK_TITLE2_LABEL" description="COM_PHOCADOWNLOAD_FIELD_MIRROR_LINK_TITLE2_DESC" />
<field name="mirror2target" type="list" class="form-select" label="COM_PHOCADOWNLOAD_MIRROR_LINK_TARGET2_LABEL" description="COM_PHOCADOWNLOAD_FIELD_MIRROR_LINK_TARGET2_DESC" default="_self" >
<option value="_self">COM_PHOCADOWNLOAD_OPEN_WINDOW_SELF</option>
<option value="_blank">COM_PHOCADOWNLOAD_OPEN_WINDOW_BLANK</option>
<option value="_parent">COM_PHOCADOWNLOAD_OPEN_WINDOW_PARENT</option>
<option value="_top">COM_PHOCADOWNLOAD_OPEN_WINDOW_TOP</option>
</field>
<field name="video_filename" type="text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_VIDEO_LINK_LABEL" description="COM_PHOCADOWNLOAD_VIDEO_LINK_DESC" />
<field name="description" type="editor" buttons="true" filter="\Joomla\CMS\Component\ComponentHelper::filterText" label="COM_PHOCADOWNLOAD_FIELD_DESCRIPTION_LABEL" description="COM_PHOCADOWNLOAD_FIELD_DESCRIPTION_DESC" />
<field name="features" type="editor" buttons="true" label="COM_PHOCADOWNLOAD_FIELD_FEATURES_LABEL" filter="\Joomla\CMS\Component\ComponentHelper::filterText" description="COM_PHOCADOWNLOAD_FIELD_FEATURES_DESC" />
<field name="changelog" type="editor" buttons="true" label="COM_PHOCADOWNLOAD_FIELD_CHANGELOG_LABEL" filter="\Joomla\CMS\Component\ComponentHelper::filterText" description="COM_PHOCADOWNLOAD_FIELD_CHANGELOG_DESC" />
<field name="notes" type="editor" buttons="true" label="COM_PHOCADOWNLOAD_FIELD_NOTES_LABEL" filter="\Joomla\CMS\Component\ComponentHelper::filterText" description="COM_PHOCADOWNLOAD_FIELD_NOTES_DESC" />
<field name="metakey" type="textarea"
label="JField_Meta_Keywords_Label" description="JField_Meta_Keywords_Desc"
class="form-control" rows="3" cols="30" />
<field name="metadesc" type="textarea"
label="JField_Meta_Description_Label" description="JField_Meta_Description_Desc"
class="form-control" rows="3" cols="30" />
</fieldset>
<fieldset name="publish" label="COM_PHOCADOWNLOAD_GROUP_LABEL_PUBLISHING_DETAILS" >
<field name="published" type="list" label="COM_PHOCADOWNLOAD_FIELD_PUBLISHED_LABEL" description="COM_PHOCADOWNLOAD_FIELD_PUBLISHED_DESC" class="form-select" size="1" default="1">
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
<field name="approved" type="list" label="COM_PHOCADOWNLOAD_FIELD_APPROVED_LABEL" description="COM_PHOCADOWNLOAD_FIELD_APPROVED_DESC" class="form-select" size="1" default="1">
<option value="1">COM_PHOCADOWNLOAD_APPROVED</option>
<option value="0">COM_PHOCADOWNLOAD_NOT_APPROVED</option>
</field>
<field name="language" type="contentlanguage" label="JFIELD_LANGUAGE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_LANGUAGE_FILE_DESC" class="form-select">
<option value="*">JALL</option>
</field>
<field name="date" type="Calendar" class="form-control" label="COM_PHOCADOWNLOAD_FIELD_DATE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_DATE_DESC" showtime="true" filter="user_utc" translateformat="true" />
<field name="publish_up" type="Calendar" class="form-control" label="COM_PHOCADOWNLOAD_FIELD_START_PUBLISHING_LABEL" description="COM_PHOCADOWNLOAD_FIELD_START_PUBLISHING_DESC" showtime="true" filter="user_utc" translateformat="true" />
<field name="publish_down" type="Calendar" class="form-control" label="COM_PHOCADOWNLOAD_FIELD_FINISH_PUBLISHING_LABEL" description="COM_PHOCADOWNLOAD_FIELD_FINISH_PUBLISHING_DESC" showtime="true" filter="user_utc" translateformat="true" />
<field name="hits" type="Text" class="form-control" size="6" label="COM_PHOCADOWNLOAD_FIELD_DOWNLOADS_LABEL" description="COM_PHOCADOWNLOAD_FIELD_DOWNLOADS_DESC" />
<field name="tags" type="phocatags" multiple="1" label="COM_PHOCADOWNLOAD_FIELD_TAGS_LABEL" description="COM_PHOCADOWNLOAD_FIELD_TAGS_DESC" layout="joomla.form.field.list-fancy-select" size="1" />
<field name="tags_string" type="text" label="COM_PHOCADOWNLOAD_FIELD_TAGS_STRING_LABEL" description="COM_PHOCADOWNLOAD_FIELD_TAGS_STRING_DESC" class="form-control" size="1" />
<field name="token" type="phocadownloadtoken" label="COM_PHOCADOWNLOAD_FIELD_TOKEN_LABEL" description="COM_PHOCADOWNLOAD_FIELD_TOKEN_DESC" class="form-control" size="40" />
<field name="tokenhits" type="text" label="COM_PHOCADOWNLOAD_FIELD_TOKENHITS_LABEL" description="COM_PHOCADOWNLOAD_FIELD_TOKENHITS_DESC" class="form-control" size="40" />
</fieldset>
<fields name="metadata">
<fieldset name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
<!--
<field name="robots" type="list"
label="JField_Metadata_Robots_Label" description="JField_Metadata_Robots_Desc"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JGLOBAL_INDEX_FOLLOW</option>
<option value="1">JGLOBAL_NOINDEX_FOLLOW</option>
<option value="2">JGLOBAL_INDEX_NOFOLLOW</option>
<option value="3">JGLOBAL_NOINDEX_NOFOLLOW</option>
<option value="4">JGLOBAL_NO_ROBOTS_TAG</option>
</field>
<field name="author" type="text" label="JAUTHOR"
description="JField_Metadata_Author_Desc" size="20" />
<field name="rights" type="text"
label="JFIELD_META_RIGHTS_LABEL" description="JFIELD_META_RIGHTS_DESC"
required="" filter="string" cols="30" rows="2" /> -->
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<field name="id" type="text" default="0" label="JGLOBAL_FIELD_ID_LABEL" required="true" readonly="true" class="readonly" />
<field name="categories" type="editor" height="400" buttons="true" hide="pagebreak,readmore" label="COM_PHOCADOWNLOAD_FIELD_CATEGORIES_LAYOUT_LABEL" filter="\Joomla\CMS\Component\ComponentHelper::filterText" description="COM_PHOCADOWNLOAD_FIELD_CATEGORIES_LAYOUT_DESC" />
<field name="category" type="editor" height="400" buttons="true" hide="pagebreak,readmore" label="COM_PHOCADOWNLOAD_FIELD_CATEGORY_LAYOUT_LABEL" filter="\Joomla\CMS\Component\ComponentHelper::filterText" description="COM_PHOCADOWNLOAD_FIELD_CATEGORY_LAYOUT_DESC" />
<field name="file" type="editor" height="400" buttons="true" hide="pagebreak,readmore" label="COM_PHOCADOWNLOAD_FIELD_FILE_LAYOUT_LABEL" filter="\Joomla\CMS\Component\ComponentHelper::filterText" description="COM_PHOCADOWNLOAD_FIELD_FILE_LAYOUT_DESC" />
</fieldset>
</form>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<field name="id" type="text" default="0" label="JGLOBAL_FIELD_ID_LABEL" required="true" readonly="true" class="readonly" />
<field name="title" type="text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_FIELD_TITLE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_TITLE_DESC" required="true" />
<field name="alias" type="text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_FIELD_ALIAS_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ALIAS_DESC" />
<field name="ordering" type="PhocaDownloadOrdering" table="file" class="form-select" label="COM_PHOCADOWNLOAD_FIELD_ORDERING_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ORDERING_DESC" />
<field name="description" type="editor" buttons="true" hide="pagebreak,readmore" label="COM_PHOCADOWNLOAD_FIELD_LICENSE_TEXT_LABEL" filter="\Joomla\CMS\Component\ComponentHelper::filterText" description="COM_PHOCADOWNLOAD_FIELD_LICENSE_TEXT_DESC" />
</fieldset>
<fieldset name="publish" label="COM_PHOCADOWNLOAD_GROUP_LABEL_PUBLISHING_DETAILS" >
<field name="published" type="list" label="COM_PHOCADOWNLOAD_FIELD_PUBLISHED_LABEL" description="COM_PHOCADOWNLOAD_FIELD_PUBLISHED_DESC" class="form-select" size="1" default="1">
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
</fieldset>
</form>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<field name="title" type="text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_FIELD_TITLE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_TITLE_M_DESC" />
<field name="alias" type="text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_FIELD_ALIAS_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ALIAS_M_DESC" />
<field name="catid" type="phocadownloadcategory" label="COM_PHOCADOWNLOAD_FIELD_CATEGORY_LABEL" description="COM_PHOCADOWNLOAD_FIELD_CATEGORY_DESC" />
<field name="published" type="list" label="COM_PHOCADOWNLOAD_FIELD_PUBLISHED_LABEL" description="COM_PHOCADOWNLOAD_FIELD_PUBLISHED_DESC" class="form-select" size="1" default="1">
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
<field name="approved" type="list" label="COM_PHOCADOWNLOAD_FIELD_APPROVED_LABEL" description="COM_PHOCADOWNLOAD_FIELD_APPROVED_DESC" class="form-select" size="1" default="1">
<option value="1">COM_PHOCADOWNLOAD_APPROVED</option>
<option value="0">COM_PHOCADOWNLOAD_NOT_APPROVED</option>
</field>
<field name="language" type="contentlanguage" label="JFIELD_LANGUAGE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_LANGUAGE_FILE_DESC" class="form-select">
<option value="*">JALL</option>
</field>
<!--
<field name="pap_copy_m" type="list" label="COM_PHOCADOWNLOAD_FIELD_COPY_PAP_LABEL" description="COM_PHOCADOWNLOAD_FIELD_COPY_PAP_DESC" class="form-control" size="1" default="0">
<option value="0">COM_PHOCADOWNLOAD_NO</option>
<option value="1">COM_PHOCADOWNLOAD_YES</option>
</field>-->
</fieldset>
</form>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<field name="id" type="text" default="0" label="JGLOBAL_FIELD_ID_LABEL" required="true" readonly="true" class="readonly" />
<field name="title" type="text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_FIELD_TITLE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_TITLE_DESC" required="true" />
<field name="alias" type="text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_FIELD_ALIAS_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ALIAS_DESC" />
<field name="type" type="hidden" default="0" label="COM_PHOCADOWNLOAD_FIELD_TYPE_LABEL" required="true" readonly="true" class="readonly" />
<field name="typeoutput" type="text" default="COM_PHOCADOWNLOAD_CUSTOM_CSS" label="COM_PHOCADOWNLOAD_FIELD_TYPE_LABEL" required="true" readonly="true" class="readonly" />
<field name="filename" type="text" default="" label="COM_PHOCADOWNLOAD_FIELD_FILENAME_LABEL" readonly="true" class="readonly" />
<field name="ordering" type="phocadownloadOrdering" table="styles" class="form-select" label="COM_PHOCADOWNLOAD_FIELD_ORDERING_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ORDERING_DESC" />
<field name="source" type="editor" editor="codemirror|none" buttons="no" label="COM_PHOCADOWNLOAD_FIELD_CSS_LABEL" description="COM_PHOCADOWNLOAD_FIELD_CSS_DESC" filter="raw" height="400" />
</fieldset>
<fieldset name="publish" label="COM_PHOCADOWNLOAD_GROUP_LABEL_PUBLISHING_DETAILS" >
<field name="published" type="list" label="COM_PHOCADOWNLOAD_FIELD_PUBLISHED_LABEL" description="COM_PHOCADOWNLOAD_FIELD_PUBLISHED_DESC" class="form-select" size="1" default="1">
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
<field name="menulink" type="text" default="" label="COM_PHOCADOWNLOAD_FIELD_CSS_MENULINK_ID_LABEL" description="COM_PHOCADOWNLOAD_FIELD_CSS_MENULINK_ID_DESC" />
</fieldset>
</form>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_phocadownload/models/fields">
<field name="id" type="text" default="0" label="JGLOBAL_FIELD_ID_LABEL" required="true" readonly="true" class="readonly" />
<field name="title" type="text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_FIELD_TITLE_LABEL" description="COM_PHOCADOWNLOAD_FIELD_TITLE_DESC" required="true" />
<field name="alias" type="text" class="form-control" size="40" label="COM_PHOCADOWNLOAD_FIELD_ALIAS_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ALIAS_DESC" />
<field name="link_cat" type="phocadownloadcategory" label="COM_PHOCADOWNLOAD_FIELD_CATEGORY_LINK_LABEL" description="COM_PHOCADOWNLOAD_FIELD_CATEGORY_LINK_DESC" />
<field name="link_ext" type="text" label="COM_PHOCADOWNLOAD_FIELD_EXT_LINK_TAG_LABEL" description="COM_PHOCADOWNLOAD_FIELD_EXT_LINK_TAG_DESC" class="form-control" size="40" />
<field name="ordering" type="PhocaDownloadOrdering" table="tag" class="form-select" label="COM_PHOCADOWNLOAD_FIELD_ORDERING_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ORDERING_DESC" />
<field name="description" type="editor" buttons="true" hide="pagebreak,readmore" class="form-control" label="COM_PHOCADOWNLOAD_FIELD_DESCRIPTION_LABEL" filter="\Joomla\CMS\Component\ComponentHelper::filterText" description="COM_PHOCADOWNLOAD_FIELD_DESCRIPTION_DESC" />
</fieldset>
<fieldset name="publish" label="COM_PHOCADOWNLOAD_GROUP_LABEL_PUBLISHING_DETAILS" >
<field name="published" type="list" label="COM_PHOCADOWNLOAD_FIELD_PUBLISHED_LABEL" description="COM_PHOCADOWNLOAD_FIELD_PUBLISHED_DESC" class="form-select" size="1" default="1">
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
</field>
</fieldset>
</form>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,683 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined( '_JEXEC' ) or die();
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
use Joomla\Registry\Registry;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Language\Text;
jimport('joomla.application.component.modeladmin');
use Joomla\String\StringHelper;
class PhocaDownloadCpModelPhocaDownloadCat extends AdminModel
{
protected $option = 'com_phocadownload';
protected $text_prefix = 'com_phocadownload';
public $typeAlias = 'com_phocadownload.phocadownloadcat';
protected function canDelete($record) {
$user = Factory::getUser();
if (!empty($record->catid)) {
return $user->authorise('core.delete', 'com_phocadownload.phocadownloadcat.'.(int) $record->catid);
} else {
return parent::canDelete($record);
}
}
protected function canEditState($record){
$user = Factory::getUser();
if (!empty($record->catid)) {
return $user->authorise('core.edit.state', 'com_phocadownload.phocadownloadcat.'.(int) $record->catid);
} else {
return parent::canEditState($record);
}
}
public function getTable($type = 'PhocaDownloadCat', $prefix = 'Table', $config = array()){
return Table::getInstance($type, $prefix, $config);
}
public function getForm($data = array(), $loadData = true) {
$app = Factory::getApplication();
$form = $this->loadForm('com_phocadownload.phocadownloadcat', 'phocadownloadcat', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_phocadownload.edit.phocadownloadcat.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
public function getItem($pk = null) {
if ($item = parent::getItem($pk)) {
// Convert the params field to an array.
if (isset($item->metadata)) {
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
protected function prepareTable($table){
jimport('joomla.filter.output');
$date = Factory::getDate();
$user = Factory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = ApplicationHelper::stringURLSafe($table->alias);
$table->parent_id = PhocaDownloadUtils::getIntFromString($table->parent_id);
if (empty($table->alias)) {
$table->alias = ApplicationHelper::stringURLSafe($table->title);
}
if (empty($table->id)) {
// Set the values
//$table->created = $date->toSql();
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = Factory::getDbo();
$db->setQuery('SELECT MAX(ordering) FROM #__phocadownload_categories');
$max = $db->loadResult();
$table->ordering = $max+1;
}
} else {
// Set the values
//$table->modified = $date->toSql();
//$table->modified_by = $user->get('id');
}
}
protected function getReorderConditions($table = null)
{
$condition = array();
$condition[] = 'parent_id = '. (int) $table->parent_id;
//$condition[] = 'state >= 0';
return $condition;
}
/*
* Custom Save method - libraries/joomla/application/component/modeladmin.php
*/
public function save($data)
{
$app = Factory::getApplication();
// = = = = = = = = = =
// Default VALUES FOR Rights in FRONTEND
// ACCESS - 0: all users can see the category (registered or not registered)
// if registered or not registered it will be set in ACCESS LEVEL not here)
// if -1 - user was not selected so every registered or special users can see category
// UPLOAD - -2: nobody can upload or add images in front (if 0 - every users can do it)
// DELETE - -2: nobody can upload or add images in front (if 0 - every users can do it)
if(!isset($data['accessuserid'])) { $data['accessuserid'] = array();}
if(!isset($data['uploaduserid'])) { $data['uploaduserid'] = array();}
if(!isset($data['deleteuserid'])) { $data['deleteuserid'] = array();}
$accessUserIdArray = PhocaDownloadUtils::toArray($data['accessuserid']);
$uploadUserIdArray = PhocaDownloadUtils::toArray($data['uploaduserid']);
$deleteUserIdArray = PhocaDownloadUtils::toArray($data['deleteuserid']);
if (isset($data['access']) && (int)$data['access'] > 0 && (int)$accessUserIdArray[0] == 0) {
$accessUserId[0] = -1;
}
$data['accessuserid'] = implode(',',$accessUserIdArray);
$data['uploaduserid'] = implode(',',$uploadUserIdArray);
$data['deleteuserid'] = implode(',',$deleteUserIdArray);
// = = = = = = = = = =
// Initialise variables;
//$dispatcher = JEventDispatcher::getInstance();
$table = $this->getTable();
$pk = (!empty($data['id'])) ? $data['id'] : (int)$this->getState($this->getName().'.id');
$isNew = true;
// Include the content plugins for the on save events.
PluginHelper::importPlugin('content');
// Load the row if saving an existing record.
if ($pk > 0) {
$table->load($pk);
$isNew = false;
}
// Bind the data.
if (!$table->bind($data)) {
throw new Exception($table->getError(), 500);
return false;
}
if(intval($table->date) == 0) {
$table->date = Factory::getDate()->toSql();
}
// Prepare the row for saving
$this->prepareTable($table);
// Check the data.
if (!$table->check()) {
throw new Exception($table->getError(), 500);
return false;
}
// Trigger the onContentBeforeSave event.
/*$result = Factory::getApplication()->triggerEvent($this->event_before_save, array($this->option.'.'.$this->name, $table, $isNew, $data));
if (in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}*/
/*
$result = $dispatcher->trigger($this->event_before_save, array($this->option.'.'.$this->name, $table, $isNew));
if (in_array(false, $result, true)) {
throw new Exception($table->getError(), 500);
return false;
}*/
PluginHelper::importPlugin($this->events_map['save']);
$result = $app->triggerEvent($this->event_before_save, array($this->option.'.'.$this->name, $table, $isNew, $data));
if (\in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}
// Store the data.
if (!$table->store()) {
throw new Exception($table->getError(), 500);
return false;
}
// Clean the cache.
$cache = Factory::getCache($this->option);
$cache->clean();
// Trigger the onContentAfterSave event.
//$dispatcher->trigger($this->event_after_save, array($this->option.'.'.$this->name, $table, $isNew));
//PluginHelper::importPlugin($this->events_map['save']);
$result = $app->triggerEvent($this->event_after_save, array($this->option.'.'.$this->name, $table, $isNew, $data));
if (\in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}
$pkName = $table->getKeyName();
if (isset($table->$pkName)) {
$this->setState($this->getName().'.id', $table->$pkName);
}
$this->setState($this->getName().'.new', $isNew);
return true;
}
function delete(&$cid = array()) {
$app = Factory::getApplication();
$db = Factory::getDBO();
$result = false;
if (count( $cid )) {
ArrayHelper::toInteger($cid);
$cids = implode( ',', $cid );
// FIRST - if there are subcategories - - - - -
$query = 'SELECT c.id, c.name, c.title, COUNT( s.parent_id ) AS numcat'
. ' FROM #__phocadownload_categories AS c'
. ' LEFT JOIN #__phocadownload_categories AS s ON s.parent_id = c.id'
. ' WHERE c.id IN ( '.$cids.' )'
. ' GROUP BY c.id'
;
$db->setQuery( $query );
if (!($rows2 = $db->loadObjectList())) {
throw new Exception($db->stderr('Load Data Problem'), 500);
return false;
}
// Add new CID without categories which have subcategories (we don't delete categories with subcat)
$err_cat = array();
$cid = array();
foreach ($rows2 as $row) {
if ($row->numcat == 0) {
$cid[] = (int) $row->id;
} else {
$err_cat[] = $row->title;
}
}
// - - - - - - - - - - - - - - -
// Images with new cid - - - - -
$err_img = array();
if (count( $cid )) {
ArrayHelper::toInteger($cid);
$cids = implode( ',', $cid );
// Select id's from phocadownload tables. If the category has some images, don't delete it
$query = 'SELECT c.id, c.name, c.title, COUNT( s.catid ) AS numcat'
. ' FROM #__phocadownload_categories AS c'
. ' LEFT JOIN #__phocadownload AS s ON s.catid = c.id'
. ' WHERE c.id IN ( '.$cids.' )'
. ' GROUP BY c.id';
$db->setQuery( $query );
if (!($rows = $db->loadObjectList())) {
throw new Exception($db->stderr('Load Data Problem'), 500);
return false;
}
$cid = array();
foreach ($rows as $row) {
if ($row->numcat == 0) {
$cid[] = (int) $row->id;
} else {
$err_img[] = $row->title;
}
}
$table = $this->getTable();
if (count( $cid )) {
$cids = implode( ',', $cid );
/*$query = 'DELETE FROM #__phocadownload_categories'
. ' WHERE id IN ( '.$cids.' )';
$db->setQuery( $query );
if (!$db->execute()) {
throw new Exception($db->getError());
return false;
}*/
PluginHelper::importPlugin($this->events_map['delete']);
foreach ($cid as $i => $pk) {
if ($table->load($pk)) {
if ($this->canDelete($table)) {
if (!$table->delete($pk)) {
throw new Exception($table->getError(), 500);
return false;
}
$app->triggerEvent($this->event_after_delete, array($this->option.'.'.$this->name, $table));
}
}
}
// Delete items in phocadownload_user_category
/* $query = 'DELETE FROM #__phocadownload_user_category'
. ' WHERE catid IN ( '.$cids.' )';
$db->setQuery( $query );
if (!$db->query()) {
throw new Exception($this->_db->getErrorMsg(), 500);
return false;
}*/
}
}
// There are some images in the category - don't delete it
$msg = '';
if (!empty( $err_cat ) || !empty( $err_img )) {
if (!empty( $err_cat )) {
$cids_cat = implode( ", ", $err_cat );
$msg .= Text::plural( 'COM_PHOCADOWNLOAD_ERROR_DELETE_CONTAIN_CAT', $cids_cat );
}
if (!empty( $err_img )) {
$cids_img = implode( ", ", $err_img );
$msg .= Text::plural( 'COM_PHOCADOWNLOAD_ERROR_DELETE_CONTAIN_FILE', $cids_img );
}
$link = 'index.php?option=com_phocadownload&view=phocadownloadcats';
$app->enqueueMessage($msg, 'error');
$app->redirect($link);
}
}
return true;
}
protected function batchCopy($value, $pks, $contexts)
{
$categoryId = (int) $value;
$app = Factory::getApplication();
$table = $this->getTable();
$db = $this->getDbo();
// Check that the category exists
if ($categoryId) {
$categoryTable = Table::getInstance('PhocaDownloadCat', 'Table');
if (!$categoryTable->load($categoryId)) {
if ($error = $categoryTable->getError()) {
// Fatal error
throw new Exception($error, 500);
return false;
}
else {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'), 500);
return false;
}
}
}
//if (empty($categoryId)) {
if (!isset($categoryId)) {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'), 500);
return false;
}
// Check that the user has create permission for the component
$extension = Factory::getApplication()->input->getCmd('option');
$user = Factory::getUser();
if (!$user->authorise('core.create', $extension)) {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE'), 500);
return false;
}
//$i = 0;
// Parent exists so we let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$table->reset();
// Check that the row actually exists
if (!$table->load($pk)) {
if ($error = $table->getError()) {
// Fatal error
throw new Exception($error, 500);
return false;
}
else {
// Not fatal error
$app->enqueueMessage(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk), 'error');
continue;
}
}
// Alter the title & alias
$data = $this->generateNewTitle($categoryId, $table->alias, $table->title);
$table->title = $data['0'];
$table->alias = $data['1'];
// Reset the ID because we are making a copy
$table->id = 0;
// New category ID
$table->parent_id = $categoryId;
// Ordering
$table->ordering = $this->increaseOrdering($categoryId);
$table->hits = 0;
// Check the row.
if (!$table->check()) {
throw new Exception($table->getError(), 500);
return false;
}
// Store the row.
if (!$table->store()) {
throw new Exception($table->getError(), 500);
return false;
}
// Get the new item ID
$newId = $table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
//$i++;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
protected function batchMove($value, $pks, $contexts)
{
$categoryId = (int) $value;
$app = Factory::getApplication();
$table = $this->getTable();
//$db = $this->getDbo();
// Check that the category exists
if ($categoryId) {
$categoryTable = Table::getInstance('PhocaDownloadCat', 'Table');
if (!$categoryTable->load($categoryId)) {
if ($error = $categoryTable->getError()) {
// Fatal error
throw new Exception($error, 500);
return false;
}
else {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'), 500);
return false;
}
}
}
//if (empty($categoryId)) {
if (!isset($categoryId)) {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'), 500);
return false;
}
// Check that user has create and edit permission for the component
$extension = Factory::getApplication()->input->getCmd('option');
$user = Factory::getUser();
if (!$user->authorise('core.create', $extension)) {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE'), 500);
return false;
}
if (!$user->authorise('core.edit', $extension)) {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'), 500);
return false;
}
// Parent exists so we let's proceed
foreach ($pks as $pk)
{
// Check that the row actually exists
if (!$table->load($pk)) {
if ($error = $table->getError()) {
// Fatal error
throw new Exception($error, 500);
return false;
}
else {
// Not fatal error
$app->enqueueMessage(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk), 'error');
continue;
}
}
// Set the new category ID
$table->parent_id = $categoryId;
// Cannot move the node to be a child of itself.
if ((int)$table->id == (int)$categoryId) {
throw new Exception(Text::sprintf('JLIB_DATABASE_ERROR_INVALID_NODE_RECURSION', get_class($pk)), 500);
return false;
}
// Check the row.
if (!$table->check()) {
throw new Exception($table->getError(), 500);
return false;
}
// Store the row.
if (!$table->store()) {
throw new Exception($table->getError(), 500);
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
public function increaseOrdering($categoryId) {
$ordering = 1;
$this->_db->setQuery('SELECT MAX(ordering) FROM #__phocadownload_categories WHERE parent_id='.(int)$categoryId);
$max = $this->_db->loadResult();
$ordering = $max + 1;
return $ordering;
}
public function batch($commands, $pks, $contexts)
{
// Sanitize user ids.
$pks = array_unique($pks);
ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true)) {
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks)) {
throw new Exception(Text::_('JGLOBAL_NO_ITEM_SELECTED'), 500);
return false;
}
$done = false;
if (!empty($commands['assetgroup_id'])) {
if (!$this->batchAccess($commands['assetgroup_id'], $pks, $contexts)) {
return false;
}
$done = true;
}
//PHOCAEDIT - Parent is by Phoca 0 not 1 like by Joomla!
$comCat =false;
if ($commands['category_id'] == '') {
$comCat = false;
} else if ( $commands['category_id'] == '0') {
$comCat = true;
} else if ((int)$commands['category_id'] > 0) {
$comCat = true;
}
if ($comCat)
//if (isset($commands['category_id']))
{
$cmd = ArrayHelper::getValue($commands, 'move_copy', 'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands['category_id'], $pks, $contexts);
if (is_array($result))
{
$pks = $result;
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands['category_id'], $pks, $contexts))
{
return false;
}
$done = true;
}
if (!empty($commands['language_id']))
{
if (!$this->batchLanguage($commands['language_id'], $pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done) {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'), 500);
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
protected function generateNewTitle($category_id, $alias, $title)
{
// Alter the title & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias, 'parent_id' => $category_id)))
{
$title = StringHelper::increment($title);
$alias = StringHelper::increment($alias, 'dash');
}
return array($title, $alias);
}
}
?>

View File

@ -0,0 +1,297 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined( '_JEXEC' ) or die();
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
jimport('joomla.application.component.modellist');
class PhocaDownloadCpModelPhocaDownloadCats extends ListModel
{
protected $option = 'com_phocadownload';
protected $total = 0;
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'alias', 'a.alias',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'category_id', 'category_id',
'state', 'a.state',
'access', 'a.access', 'access_level',
'ordering', 'a.ordering',
'language', 'a.language',
'hits', 'a.hits',
'average', 'v.average',
'published','a.published',
'autorized', 'a.approved',
'owner_id','a.owner_id',
'parentcat_title', 'parentcat_title',
'level', 'level'
);
}
parent::__construct($config);
}
protected function populateState($ordering = 'a.title', $direction = 'ASC')
{
// Initialise variables.
$app = Factory::getApplication('administrator');
// Load the filter state.
$search = $app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int');
$this->setState('filter.access', $accessId);
$state = $app->getUserStateFromRequest($this->context.'.filter.published', 'filter_published', '', 'string');
$this->setState('filter.published', $state);
// Not used in SQL - used in view in recursive category tree function
$levels = $app->getUserStateFromRequest($this->context.'.filter.level', 'filter_level', '', 'string');
$this->setState('filter.level', $levels);
$categoryId = $app->getUserStateFromRequest($this->context.'.filter.parent_id', 'filter_parent_id', null);
$this->setState('filter.parent_id', $categoryId);
$language = $app->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
// Load the parameters.
$params = ComponentHelper::getParams('com_phocadownload');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.search');
$id .= ':'.$this->getState('filter.access');
$id .= ':'.$this->getState('filter.published');
$id .= ':'.$this->getState('filter.category_id');
$id .= ':'.$this->getState('filter.file_id');
return parent::getStoreId($id);
}
/*
* Because of tree we need to load all the items
*
* We need to load all items because of creating tree
* After creating tree we get info from pagination
* and will set displaying of categories for current pagination
* E.g. pagination is limitstart 5, limit 5 - so only categories from 5 to 10 will be displayed (in Default.php)
*/
public function getItems()
{
// Get a storage key.
$store = $this->getStoreId();
// Try to load the data from internal storage.
if (!empty($this->cache[$store])) {
return $this->cache[$store];
}
// Load the list items.
//$query = $this->getListQuery();
//$items = $this->_getList($query, $this->getState('list.start'), $this->getState('list.limit'));
//$items = $this->_getList($query);
// Check for a database error.
/* if ($this->_db->getErrorNum()) {
throw new Exception($this->_db->getErrorMsg(), 500);
return false;
}*/
try {
// Load the list items.
$query = $this->getListQuery();
//$items = $this->_getList($query, $this->getState('list.start'), $this->getState('list.limit'));
$items = $this->_getList($query);
} catch (RuntimeException $e) {
throw new Exception($e->getMessage(), 500);
return false;
}
// Add the items to the internal cache.
$this->cache[$store] = $items;
return $this->cache[$store];
}
protected function getListQuery()
{
/*
$query = ' SELECT a.*, cc.title AS parentname, u.name AS editor, v.average AS ratingavg, ua.username AS usercatname, c.countid AS countid, ag.title AS access_level'
. ' FROM #__phocadownload_categories AS a '
. ' LEFT JOIN #__users AS u ON u.id = a.checked_out '
. ' LEFT JOIN #__viewlevels AS ag ON ag.id = a.access '
. ' LEFT JOIN #__phocadownload_categories AS cc ON cc.id = a.parent_id'
. ' LEFT JOIN #__phocadownload_votes_statistics AS v ON v.catid = a.id'
. ' LEFT JOIN #__users AS ua ON ua.id = a.owner_id'
. ' JOIN (SELECT c.parent_id, count(*) AS countid'
. ' FROM #__phocadownload_categories AS c'
.' GROUP BY c.parent_id ) AS c'
.' ON a.parent_id = c.parent_id'
. $where
. $orderby;
*/
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from('`#__phocadownload_categories` AS a');
// Join over the language
$query->select('l.title AS language_title');
$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Join over the asset groups.
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Join over the categories.
$query->select('c.title AS parentcat_title, c.id AS parentcat_id');
$query->join('LEFT', '#__phocadownload_categories AS c ON c.id = a.parent_id');
//$query->select('ua.id AS userid, ua.username AS username, ua.name AS usernameno');
//$query->join('LEFT', '#__users AS ua ON ua.id = a.owner_id');
$query->select('cc.countid AS countid');
$query->join('LEFT', '(SELECT cc.parent_id, count(*) AS countid'
. ' FROM #__phocadownload_categories AS cc'
.' GROUP BY cc.parent_id ) AS cc'
.' ON a.parent_id = cc.parent_id');
// Filter by access level.
if ($access = $this->getState('filter.access')) {
$query->where('a.access = '.(int) $access);
}
// Filter by published state.
$published = $this->getState('filter.published');
if (is_numeric($published)) {
$query->where('a.published = '.(int) $published);
}
else if ($published === '') {
$query->where('(a.published IN (0, 1))');
}
// Filter by category.
$categoryId = $this->getState('filter.parent_id');
if (is_numeric($categoryId)) {
$query->where('a.parent_id = ' . (int) $categoryId);
}
// Filter on the language.
if ($language = $this->getState('filter.language')) {
$query->where('a.language = ' . $db->quote($language));
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
}
else
{
$search = $db->Quote('%'.$db->escape($search, true).'%');
$query->where('( a.title LIKE '.$search.' OR a.alias LIKE '.$search.')');
}
}
//$query->group('a.id');
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering', 'title');
$orderDirn = $this->state->get('list.direction', 'asc');
/*if ($orderCol == 'a.ordering' || $orderCol == 'parentcat_title') {
$orderCol = 'parentcat_title '.$orderDirn.', a.ordering';
}*/
$query->order($db->escape($orderCol.' '.$orderDirn));
//echo nl2br(str_replace('#__', 'jos_', $query->__toString()));
return $query;
}
public function getTotal() {
$store = $this->getStoreId('getTotal');
if (isset($this->cache[$store])) {
return $this->cache[$store];
}
// PHOCAEDIT
if (isset($this->total) && (int)$this->total > 0) {
$total = (int)$this->total;
} else {
$query = $this->_getListQuery();
try {
$total = (int) $this->_getListCount($query);
}
catch (RuntimeException $e) {
throw new Exception($e->getMessage(), 500);
return false;
}
}
$this->cache[$store] = $total;
return $this->cache[$store];
}
public function setTotal($total) {
// When we use new total and new pagination, we need to clean their cache
$store1 = $this->getStoreId('getTotal');
$store2 = $this->getStoreId('getStart');
$store3 = $this->getStoreId('getPagination');
unset($this->cache[$store1]);
unset($this->cache[$store2]);
unset($this->cache[$store3]);
$this->total = (int)$total;
}
}
?>

View File

@ -0,0 +1,146 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined('_JEXEC') or die();
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
use Joomla\Registry\Registry;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\Utilities\ArrayHelper;
jimport('joomla.application.component.modeladmin');
class PhocaDownloadCpModelPhocaDownloadDownload extends AdminModel
{
protected $option = 'com_phocadownload';
protected $text_prefix = 'com_phocadownload';
public $typeAlias = 'com_phocadownload.phocadownloaddownload';
protected function canDelete($record)
{
$user = Factory::getUser();
if (!empty($record->catid)) {
return $user->authorise('core.delete', 'com_phocadownload.phocadownloaddownload.'.(int) $record->catid);
} else {
return parent::canDelete($record);
}
}
public function getTable($type = 'PhocaDownloadDownload', $prefix = 'Table', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
public function getForm($data = array(), $loadData = true) {
$app = Factory::getApplication();
$form = $this->loadForm('com_phocadownload.phocadownloaddownload', 'phocadownloaddownload', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_phocadownload.edit.phocadownload.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
public function getItem($pk = null)
{
if ($item = parent::getItem($pk)) {
// Convert the params field to an array.
if (isset($item->metadata)) {
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
protected function prepareTable($table)
{
jimport('joomla.filter.output');
$date = Factory::getDate();
$user = Factory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = ApplicationHelper::stringURLSafe($table->alias);
$table->confirm_license = PhocaDownloadUtils::getIntFromString($table->confirm_license);
$table->hits = PhocaDownloadUtils::getIntFromString($table->hits);
$table->tokenhits = PhocaDownloadUtils::getIntFromString($table->tokenhits);
if (empty($table->alias)) {
$table->alias = ApplicationHelper::stringURLSafe($table->title);
}
if (empty($table->id)) {
// Set the values
//$table->created = $date->toSql();
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = Factory::getDbo();
//$db->setQuery('SELECT MAX(ordering) FROM #__phocadownload');
$db->setQuery('SELECT MAX(ordering) FROM #__phocadownload WHERE catid = '.(int)$table->catid);
$max = $db->loadResult();
$table->ordering = $max+1;
}
}
else {
// Set the values
//$table->modified = $date->toSql();
//$table->modified_by = $user->get('id');
}
}
function delete(&$cid = array()) {
$result = false;
if (count( $cid )) {
ArrayHelper::toInteger($cid);
$cids = implode( ',', $cid );
//Delete it from DB
$query = 'DELETE FROM #__phocadownload_user_stat'
. ' WHERE id IN ( '.$cids.' )';
$this->_db->setQuery( $query );
if(!$this->_db->execute()) {
throw new Exception($this->_db->getError());
return false;
}
}
return true;
}
}
?>

View File

@ -0,0 +1,218 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined( '_JEXEC' ) or die();
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\Utilities\ArrayHelper;
jimport( 'joomla.application.component.modellist' );
class PhocaDownloadCpModelPhocaDownloadDownloads extends ListModel
{
protected $option = 'com_phocadownload';
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'd.title',
'alias', 'd.alias',
'checked_out', 'd.checked_out',
'checked_out_time', 'd.checked_out_time',
'category_id', 'category_id',
'usernameno', 'ua.usernameno',
'username', 'ua.username',
'ordering', 'a.ordering',
'count', 'a.count',
'date', 'a.date',
'published','d.published',
'filename', 'd.filename'
);
}
parent::__construct($config);
}
protected function populateState($ordering = 'username', $direction = 'ASC')
{
// Initialise variables.
$app = Factory::getApplication('administrator');
// Load the filter state.
$search = $app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
/*
$accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int');
$this->setState('filter.access', $accessId);
$state = $app->getUserStateFromRequest($this->context.'.filter.published', 'filter_published', '', 'string');
$this->setState('filter.published', $state);
*/
$id = Factory::getApplication()->input->get( 'id', '', '', 'int');
if ((int)$id > 0) {
$this->setState('filter.filestat_id', $id);
} else {
//$fileStatId = $app->getUserStateFromRequest($this->context.'.filter.filestat_id', 'filter_filestat_id', $id);
$this->setState('filter.filestat_id', 0);
}
/*
$language = $app->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);*/
// Load the parameters.
$params = ComponentHelper::getParams('com_phocadownload');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.search');
/*$id .= ':'.$this->getState('filter.access');
$id .= ':'.$this->getState('filter.published');
$id .= ':'.$this->getState('filter.category_id');*/
$id .= ':'.$this->getState('filter.filestat_id');
return parent::getStoreId($id);
}
protected function getListQuery()
{
/*$query = ' SELECT a.id, a.userid, a.fileid, d.filename AS filename, d.title AS filetitle, a.count, a.date, u.name AS uname, u.username AS username, 0 AS checked_out'
. ' FROM #__phocadownload_user_stat AS a '
. ' LEFT JOIN #__phocadownload AS d ON d.id = a.fileid '
. ' LEFT JOIN #__users AS u ON u.id = a.userid '
. $where
. ' GROUP by a.id'
. $orderby;
*/
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from('`#__phocadownload_user_stat` AS a');
// Join over the language
//$query->select('l.title AS language_title');
//$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
//$query->select('uc.name AS editor');
//$query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Join over the asset groups.
//$query->select('ag.title AS access_level');
//$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Join over the categories.
$query->select('d.filename AS filename, d.title AS filetitle');
$query->join('LEFT', '#__phocadownload AS d ON d.id = a.fileid');
$query->select('ua.id AS userid, ua.username AS username, ua.name AS usernameno');
$query->join('LEFT', '#__users AS ua ON ua.id = a.userid');
//$query->select('v.average AS ratingavg');
//$query->join('LEFT', '#__phocadownload_img_votes_statistics AS v ON v.imgid = a.id');
// Filter by access level.
//if ($access = $this->getState('filter.access')) {
// $query->where('a.access = '.(int) $access);
//}
// Filter by published state.
/*$published = $this->getState('filter.published');
if (is_numeric($published)) {
$query->where('a.published = '.(int) $published);
}
else if ($published === '') {
$query->where('(a.published IN (0, 1))');
}
// Filter by category.*/
/*$fileStatId = $this->getState('filter.filestat_id');
if (is_numeric($fileStatId)) {
$query->where('a.fileid = ' . (int) $fileStatId);
}*/
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
}
else
{
$search = $db->Quote('%'.$db->escape($search, true).'%');
$query->where('( ua.username LIKE '.$search.' OR ua.name LIKE '.$search.' OR d.filename LIKE '.$search.' OR d.title LIKE '.$search.')');
}
}
// $query->group('a.id');
// Add the list ordering clause.
//$orderCol = $this->state->get('list.ordering');
//$orderDirn = $this->state->get('list.direction');
$orderCol = $this->state->get('list.ordering', 'username');
$orderDirn = $this->state->get('list.direction', 'asc');
if ($orderCol == 'a.id' || $orderCol == 'username') {
$orderCol = 'ua.username '.$orderDirn.', a.id';
}
$query->order($db->escape($orderCol.' '.$orderDirn));
return $query;
}
function reset($cid = array()) {
if (count( $cid )) {
ArrayHelper::toInteger($cid);
$cids = implode( ',', $cid );
$date = gmdate('Y-m-d H:i:s');
//Delete it from DB
$query = 'UPDATE #__phocadownload_user_stat'
.' SET count = 0,'
.' date = '.$this->_db->Quote($date)
.' WHERE id IN ( '.$cids.' )';
$this->_db->setQuery( $query );
if(!$this->_db->execute()) {
throw new Exception($this->_db->getError());
return false;
}
}
return true;
}
}
?>

View File

@ -0,0 +1,931 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined('_JEXEC') or die();
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
use Joomla\Registry\Registry;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Filter\OutputFilter;
jimport('joomla.application.component.modeladmin');
class PhocaDownloadCpModelPhocaDownloadFile extends AdminModel
{
protected $option = 'com_phocadownload';
protected $text_prefix = 'com_phocadownload';
public $typeAlias = 'com_phocadownload.phocadownloadfile';
protected function canDelete($record)
{
$user = Factory::getUser();
if (!empty($record->catid)) {
return $user->authorise('core.delete', 'com_phocadownload.phocadownloadfile.'.(int) $record->catid);
} else {
return parent::canDelete($record);
}
}
protected function canEditState($record)
{
$user = Factory::getUser();
if (!empty($record->catid)) {
return $user->authorise('core.edit.state', 'com_phocadownload.phocadownloadfile.'.(int) $record->catid);
} else {
return parent::canEditState($record);
}
}
public function getTable($type = 'PhocaDownload', $prefix = 'Table', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
public function getForm($data = array(), $loadData = true) {
$app = Factory::getApplication();
$form = $this->loadForm('com_phocadownload.phocadownloadfile', 'phocadownloadfile', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
protected function loadFormData()
{
// Check the session for previously entered form data.
$app = Factory::getApplication('administrator');
$data = Factory::getApplication()->getUserState('com_phocadownload.edit.phocadownload.data', array());
if (empty($data)) {
$data = $this->getItem();
}
// Try to preselect category when we add new file
// Take the value from filter select box in image list
// Or take it from GET - if someone wants to add new file and wants to have preselected category
if (empty($data) || (!empty($data) && (int)$data->id < 1)) {
$filter = (array) $app->getUserState('com_phocadownload.phocadownloadfiles.filter.category_id');
if (isset($filter[0]) && (int)$filter[0] > 0) {
$data->set('catid', (int)$filter[0]);
} else {
// UNDER TEST
$catid = $app->input->get('catid');
if ((int)$catid > 0) {
$data->set('catid', (int)$catid);
}
}
}
return $data;
}
public function getItem($pk = null)
{
if ($item = parent::getItem($pk)) {
// Convert the params field to an array.
if (isset($item->metadata)) {
$registry = new Registry;
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
}
return $item;
}
protected function prepareTable($table)
{
jimport('joomla.filter.output');
$date = Factory::getDate();
$user = Factory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = ApplicationHelper::stringURLSafe($table->alias);
$table->confirm_license = PhocaDownloadUtils::getIntFromString($table->confirm_license);
$table->hits = PhocaDownloadUtils::getIntFromString($table->hits);
$table->tokenhits = PhocaDownloadUtils::getIntFromString($table->tokenhits);
if (empty($table->alias)) {
$table->alias = ApplicationHelper::stringURLSafe($table->title);
}
if (empty($table->id)) {
// Set the values
//$table->created = $date->toSql();
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = Factory::getDbo();
//$db->setQuery('SELECT MAX(ordering) FROM #__phocadownload');
$db->setQuery('SELECT MAX(ordering) FROM #__phocadownload WHERE catid = '.(int)$table->catid);
$max = $db->loadResult();
$table->ordering = $max+1;
}
}
else {
// Set the values
//$table->modified = $date->toSql();
//$table->modified_by = $user->get('id');
}
}
protected function getReorderConditions($table = null)
{
$condition = array();
$condition[] = 'catid = '. (int) $table->catid;
//$condition[] = 'state >= 0';
return $condition;
}
function approve(&$pks, $value = 1)
{
// Initialise variables.
//$dispatcher = JEventDispatcher::getInstance();
$user = Factory::getUser();
$table = $this->getTable('phocadownload');
$pks = (array) $pks;
$app = Factory::getApplication();
// Include the content plugins for the change of state event.
PluginHelper::importPlugin('content');
// Access checks.
foreach ($pks as $i => $pk) {
if ($table->load($pk)) {
if (!$this->canEditState($table)) {
// Prune items that you can't change.
unset($pks[$i]);
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_EDIT_STATE_NOT_PERMITTED'), 403);
return false;
}
}
}
// Attempt to change the state of the records.
if (!$table->approve($pks, $value, $user->get('id'))) {
throw new Exception($table->getError(), 500);
return false;
}
$context = $this->option.'.'.$this->name;
// Trigger the onContentChangeState event.
/* $result = $dispatcher->trigger($this->event_change_state, array($context, $pks, $value));
if (in_array(false, $result, true)) {
throw new Exception($table->getError(), 500);
return false;
} */
//PluginHelper::importPlugin($this->events_map['state']);
$result = $app->triggerEvent($this->event_change_state, array($context, $pks, $value));
if (\in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}
return true;
}
function save($data) {
$app = Factory::getApplication();
$input = Factory::getApplication()->input;
//$dispatcher = J Dispatcher::getInstance();
$table = $this->getTable();
$pk = (!empty($data['id'])) ? $data['id'] : (int)$this->getState($this->getName().'.id');
$isNew = true;
//$data['filesize'] = PhocaDownloadUtils::getFileSize($data['filename'], 0);
if ($data['alias'] == '') {
$data['alias'] = $data['title'];
}
//$data['alias'] = PhocaDownloadText::get AliasName($data['alias']);
// ALIAS
if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (!isset($data['id']) || (int) $data['id'] == 0)) {
if ($data['alias'] == null) {
if (Factory::getConfig()->get('unicodeslugs') == 1) {
$data['alias'] = OutputFilter::stringURLUnicodeSlug($data['title']);
} else {
$data['alias'] = OutputFilter::stringURLSafe($data['title']);
}
if ($table->load(array('alias' => $data['alias']))){
$msg = Text::_('COM_PHOCADOWNLOAD_SAVE_WARNING');
}
list($title, $alias) = $this->generateNewTitle(0, $data['alias'], $data['title']);
$data['alias'] = $alias;
if (isset($msg)) {
Factory::getApplication()->enqueueMessage($msg, 'warning');
}
}
} else if ($table->load(array('alias' => $data['alias'])) && ($table->id != $data['id'] || $data['id'] == 0)) {
$this->setError(Text::_('COM_PHOCADOWNLOAD_ERROR_ITEM_UNIQUE_ALIAS'));
return false;
}
// Initialise variables;
//$dispatcher = JEventDispatcher::getInstance();
$table = $this->getTable();
$pk = (!empty($data['id'])) ? $data['id'] : (int)$this->getState($this->getName().'.id');
$isNew = true;
// Include the content plugins for the on save events.
PluginHelper::importPlugin('content');
// Load the row if saving an existing record.
if ($pk > 0) {
$table->load($pk);
$isNew = false;
}
// =================================================
// Make a copy for play and preview
$paramsC = ComponentHelper::getParams('com_phocadownload') ;
$papCopy = $paramsC->get( 'pap_copy', 0 );
$overwriteExistingFiles = $paramsC->get( 'overwrite_existing_files', 0 );
$path = PhocaDownloadPath::getPathSet();
if ($papCopy == 2 || $papCopy == 3) {
$canPlay = PhocaDownloadFile::canPlay($data['filename']);
$canPreview = PhocaDownloadFile::canPreview($data['filename']);
$filepath = Path::clean($path['orig_abs_ds'] . '/'.$data['filename']);
$filepathPAP = Path::clean($path['orig_abs_pap_ds'] . '/'.$data['filename']);
$filepathPAPFolder = Path::clean($path['orig_abs_pap_ds'] . '/'. PhocaDownloadFile::getFolderFromTheFile($data['filename']));
if ($canPlay || $canPreview) {
// 1. UPLOAD - this is real upload to folder
// 2. STORE - this is storing info to database (e.g. download and play/preview files are identical, then there will be no copy of the file but only storing DB info
$uploadPAP = 1;// upload file for preview and play
$storePAP = 0;
// 1. Care about upload
if (File::exists($filepathPAP) && $overwriteExistingFiles == 0) {
//$errUploadMsg = JText::_("COM_PHOCADOWNLOAD_FILE_ALREADY_EXISTS");
//return false;
$uploadPAP = 0; // don't upload if it exists, it is not main file, don't do false and exit
}
// Overwrite file and add no new item to database
$fileExistsPAP = 0;
if (File::exists($filepathPAP) && $overwriteExistingFiles == 1) {
$fileExistsPAP = 1;
if ($canPlay == 1) {
// set new file only no other is set or it is the same like currect - to overwrite updated version of the same file
if ($data['filename_play'] == '' || $data['filename_play'] == $data['filename']) {
$data['filename_play'] = $data['filename'];
} else {
$uploadPAP = 0;
}
} else if ($canPreview == 1) {
// set new file only no other is set or it is the same like currect - to overwrite updated version of the same file
if ($data['filename_preview'] == '' || $data['filename_preview'] == $data['filename']) {
$data['filename_preview'] = $data['filename'];
} else {
$uploadPAP = 0;
}
}
}
if ($uploadPAP == 0) {
} else {
if (!Folder::exists($filepathPAPFolder)) {
if (Folder::create($filepathPAPFolder)) {
$dataFile = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
File::write($filepathPAPFolder . '/' ."index.html", $dataFile);
}
// else {
//$errUploadMsg = JText::_("COM_PHOCADOWNLOAD_UNABLE_TO_CREATE_FOLDER");
//return false;
//}
}
if ($filepath === $filepathPAP) {
// Don't try to copy the same file to the same file (including path) because you get error
$storePAP = 1;
} else if (!File::copy($filepath, $filepathPAP)) {
//$errUploadMsg = JText::_("COM_PHOCADOWNLOAD_UNABLE_TO_UPLOAD_FILE");
//return false;
} else {
$storePAP = 1;
}
}
// 2. Care about store
if ($filepath === $filepathPAP) {
// SPECIFIC CASE - administrator set the download folder the same like preview/play folder
// - in such case, there will be no copy because both files including path are identical
// - but we still write the info about play/preview into database
// - so no set uploadPAP to 0
$storePAP = 1;
}
if ($storePAP == 1) {
if ($canPlay == 1) {
$data['filename_play'] = $data['filename'];
} else if ($canPreview == 1) {
$data['filename_preview'] = $data['filename'];
}
}
}
}
// ==============================================
/* // =================================================
// Make a copy for play and preview
$paramsC = ComponentHelper::getParams('com_phocadownload') ;
$papCopy = $paramsC->get( 'pap_copy', 0 );
$overwriteExistingFiles = $paramsC->get( 'overwrite_existing_files', 0 );
$path = PhocaDownloadPath::getPathSet();
if ($papCopy == 2 || $papCopy == 3) {
$canPlay = PhocaDownloadFile::canPlay($data['filename']);
$canPreview = PhocaDownloadFile::canPreview($data['filename']);
$filepath = Path::clean($path['orig_abs_ds'] . '/'.$data['filename']);
$filepathPAP = Path::clean($path['orig_abs_pap_ds'] . '/'.$data['filename']);
$filepathPAPFolder = Path::clean($path['orig_abs_pap_ds'] . '/'. PhocaDownloadFile::getFolderFromTheFile($data['filename']));
if ($canPlay || $canPreview) {
$uploadPAP = 1;// upload file for preview and play
if (File::exists($filepathPAP) && $overwriteExistingFiles == 0) {
//$errUploadMsg = JText::_("COM_PHOCADOWNLOAD_FILE_ALREADY_EXISTS");
//return false;
$uploadPAP = 0; // don't upload if it exists, it is not main file, don't do false and exit
if ($canPlay == 1) {
// set new file only no other is set
if ($data['filename_play'] != '') {
$uploadPAP = 0;
} else {
$data['filename_play'] = $data['filename'];
}
} else if ($canPreview == 1) {
// set new file only no other is set
if ($data['filename_preview'] != '') {
$uploadPAP = 0;
} else {
$data['filename_preview'] = $data['filename'];
}
}
}
// Overwrite file and add no new item to database
$fileExistsPAP = 0;
if (File::exists($filepathPAP) && $overwriteExistingFiles == 1) {
$fileExistsPAP = 1;
if ($canPlay == 1) {
// set new file only no other is set or it is the same like currect - to overwrite updated version of the same file
if ($data['filename_play'] == '' || $data['filename_play'] == $data['filename']) {
$data['filename_play'] = $data['filename'];
} else {
$uploadPAP = 0;
}
} else if ($canPreview == 1) {
// set new file only no other is set or it is the same like currect - to overwrite updated version of the same file
if ($data['filename_preview'] == '' || $data['filename_preview'] == $data['filename']) {
$data['filename_preview'] = $data['filename'];
} else {
$uploadPAP = 0;
}
}
}
if ($uploadPAP == 0) {
} else {
if (!Folder::exists($filepathPAPFolder)) {
if (Folder::create($filepathPAPFolder)) {
$dataFile = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
File::write($filepathPAPFolder . '/' ."index.html", $dataFile);
}
// else {
//$errUploadMsg = JText::_("COM_PHOCADOWNLOAD_UNABLE_TO_CREATE_FOLDER");
//return false;
//}
}
if (!File::copy($filepath, $filepathPAP)) {
//$errUploadMsg = JText::_("COM_PHOCADOWNLOAD_UNABLE_TO_UPLOAD_FILE");
//return false;
} else {
if ($canPlay == 1) {
$data['filename_play'] = $data['filename'];
} else if ($canPreview == 1) {
$data['filename_preview'] = $data['filename'];
}
}
}
}
}
// ==============================================
*/
// Bind the data.
if (!$table->bind($data)) {
throw new Exception($table->getError(), 500);
return false;
}
// Date - - - - -
$nullDate = $this->_db->getNullDate();
$config = Factory::getConfig();
$tzoffset = $config->get('offset');
//$date = JFactory::getDate($table->date, $tzoffset);
//$table->date = $date->toSql();
// Append time if not added to publish date
//if (strlen(trim($table->publish_up)) <= 10) {
// $table->publish_up .= ' 00:00:00';
//}
//$date = JFactory::getDate($table->publish_up, $tzoffset);
//$table->publish_up = $date->toSql();
if ($table->id) {
// Test Solution add date when it is removed
if (!intval($table->date)) {
$date = Factory::getDate();
$table->date = $date->toSql();
}
} else {
if (!intval($table->date)) {
$date = Factory::getDate();
$table->date = $date->toSql();
}
}
if(intval($table->publish_up) == 0) {
$table->publish_up = Factory::getDate()->toSql();
}
// Handle never unpublish date
if (trim((string)$table->publish_down) == Text::_('Never') || trim( (string)$table->publish_down ) == '') {
$table->publish_down = $nullDate;
} else {
if (strlen(trim( $table->publish_down )) <= 10) {
$table->publish_down .= ' 00:00:00';
}
//$date = JFactory::getDate($table->publish_down, $tzoffset);
$date = Factory::getDate($table->publish_down);
$table->publish_down = $date->toSql();
}
// - - - - - -
// if new item, order last in appropriate group
if (!$table->id) {
$where = 'catid = ' . (int) $table->catid ;
$table->ordering = $table->getNextOrder( $where );
}
// Prepare the row for saving
$this->prepareTable($table);
// Check the data.
if (!$table->check()) {
throw new Exception($table->getError(), 500);
return false;
}
// Trigger the onContentBeforeSave event.
/*$result = $dispatcher->trigger($this->event_before_save, array($this->option.'.'.$this->name, $table, $isNew));
if (in_array(false, $result, true)) {
throw new Exception($table->getError(), 500);
return false;
}*/
/*$result = Factory::getApplication()->triggerEvent($this->event_before_save, array($this->option.'.'.$this->name, $table, $isNew, $data));
if (in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}*/
PluginHelper::importPlugin($this->events_map['save']);
$result = $app->triggerEvent($this->event_before_save, array($this->option.'.'.$this->name, $table, $isNew, $data));
if (\in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}
// Store the data.
if (!$table->store()) {
throw new Exception($table->getError(), 500);
return false;
}
// Store to ref table
if (!isset($data['tags'])) {
$data['tags'] = array();
}
if ((int)$table->id > 0) {
PhocaDownloadTag::storeTags($data['tags'], (int)$table->id);
}
// Clean the cache.
$cache = Factory::getCache($this->option);
$cache->clean();
// Trigger the onContentAfterSave event.
//$dispatcher->trigger($this->event_after_save, array($this->option.'.'.$this->name, $table, $isNew));
PluginHelper::importPlugin($this->events_map['save']);
$result = $app->triggerEvent($this->event_after_save, array($this->option.'.'.$this->name, $table, $isNew, $data));
if (\in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}
$pkName = $table->getKeyName();
if (isset($table->$pkName)) {
$this->setState($this->getName().'.id', $table->$pkName);
}
$this->setState($this->getName().'.new', $isNew);
return true;
}
function delete(&$cid = array()) {
$result = false;
$paramsC = ComponentHelper::getParams('com_phocadownload');
$deleteExistingFiles = $paramsC->get( 'delete_existing_files', 0 );
$table = $this->getTable();
if (count( $cid )) {
ArrayHelper::toInteger($cid);
$cids = implode( ',', $cid );
// - - - - - - - - - - - - -
// Get all filenames we want to delete from database, we delete all thumbnails from server of this file
$queryd = 'SELECT filename as filename FROM #__phocadownload WHERE id IN ( '.$cids.' )';
$this->_db->setQuery($queryd);
$fileObject = $this->_db->loadObjectList();
// - - - - - - - - - - - - -
//Delete it from DB
/*$query = 'DELETE FROM #__phocadownload'
. ' WHERE id IN ( '.$cids.' )';
$this->_db->setQuery( $query );
if(!$this->_db->execute()) {
throw new Exception($this->_db->getError());
return false;
}*/
$app = Factory::getApplication();
PluginHelper::importPlugin($this->events_map['delete']);
foreach ($cid as $i => $pk) {
if ($table->load($pk)) {
if ($this->canDelete($table)) {
if (!$table->delete($pk)) {
throw new Exception($table->getError(), 500);
return false;
}
$app->triggerEvent($this->event_after_delete, array($this->option.'.'.$this->name, $table));
}
}
}
//Delete tags from DB
$query = 'DELETE FROM #__phocadownload_tags_ref'
. ' WHERE fileid IN ( '.$cids.' )';
$this->_db->setQuery( $query );
if(!$this->_db->execute()) {
throw new Exception($this->_db->getError());
return false;
}
//Delete files from statistics table
$query = 'DELETE FROM #__phocadownload_user_stat'
. ' WHERE fileid IN ( '.$cids.' )';
$this->_db->setQuery( $query );
if(!$this->_db->execute()) {
throw new Exception($this->_db->getError());
return false;
}
// - - - - - - - - - - - - - -
// DELETE FILES ON SERVER
if ($deleteExistingFiles == 1) {
$path = PhocaDownloadPath::getPathSet();
foreach ($fileObject as $key => $value) {
//The file can be stored in other category - don't delete it from server because other category use it
$querys = "SELECT id as id FROM #__phocadownload WHERE filename='".$value->filename."' ";
$this->_db->setQuery($querys);
$sameFileObject = $this->_db->loadObject();
// same file in other category doesn't exist - we can delete it
if (!$sameFileObject) {
File::delete(Path::clean($path['orig_abs_ds'].$value->filename));
}
}
}
/*$app = Factory::getApplication();
PluginHelper::importPlugin($this->events_map['delete']);
$result = $app->triggerEvent($this->event_after_delete, array($this->option.'.'.$this->name, $table));
if (\in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}*/
}
return true;
}
protected function batchCopy($value, $pks, $contexts)
{
$categoryId = (int) $value;
$app = Factory::getApplication();
$table = $this->getTable();
$db = $this->getDbo();
// Check that the category exists
if ($categoryId) {
$categoryTable = Table::getInstance('PhocaDownloadCat', 'Table');
if (!$categoryTable->load($categoryId)) {
if ($error = $categoryTable->getError()) {
// Fatal error
throw new Exception($error, 500);
return false;
}
else {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'), 500);
return false;
}
}
}
if (empty($categoryId)) {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'), 500);
return false;
}
// Check that the user has create permission for the component
$extension = Factory::getApplication()->input->getCmd('option');
$user = Factory::getUser();
if (!$user->authorise('core.create', $extension)) {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE'), 500);
return false;
}
// $i = 0;
// Parent exists so we let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$table->reset();
// Check that the row actually exists
if (!$table->load($pk)) {
if ($error = $table->getError()) {
// Fatal error
throw new Exception($error, 500);
return false;
}
else {
// Not fatal error
$app->enqueueMessage(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk), 'error');
continue;
}
}
// Alter the title & alias
$data = $this->generateNewTitle($categoryId, $table->alias, $table->title);
$table->title = $data['0'];
$table->alias = $data['1'];
// Reset the ID because we are making a copy
$table->id = 0;
// New category ID
$table->catid = $categoryId;
// Ordering
$table->ordering = $this->increaseOrdering($categoryId);
$table->hits = 0;
// Check the row.
if (!$table->check()) {
throw new Exception($table->getError(), 500);
return false;
}
// Store the row.
if (!$table->store()) {
throw new Exception($table->getError(), 500);
return false;
}
$newId = $table->get('id');
// Add the new ID to the array
$newIds[$pk] = $newId;
//$i++;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Batch move articles to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
*
* @return booelan True if successful, false otherwise and internal error is set.
*
* @since 11.1
*/
protected function batchMove($value, $pks, $contexts)
{
$categoryId = (int) $value;
$app = Factory::getApplication();
$table = $this->getTable();
//$db = $this->getDbo();
// Check that the category exists
if ($categoryId) {
$categoryTable = Table::getInstance('PhocaDownloadCat', 'Table');
if (!$categoryTable->load($categoryId)) {
if ($error = $categoryTable->getError()) {
// Fatal error
throw new Exception($error, 500);
return false;
}
else {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'), 500);
return false;
}
}
}
if (empty($categoryId)) {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'), 500);
return false;
}
// Check that user has create and edit permission for the component
$extension = Factory::getApplication()->input->getCmd('option');
$user = Factory::getUser();
if (!$user->authorise('core.create', $extension)) {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE'), 500);
return false;
}
if (!$user->authorise('core.edit', $extension)) {
throw new Exception(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'), 500);
return false;
}
// Parent exists so we let's proceed
foreach ($pks as $pk)
{
// Check that the row actually exists
if (!$table->load($pk)) {
if ($error = $table->getError()) {
// Fatal error
throw new Exception($error, 500);
return false;
}
else {
// Not fatal error
$app->enqueueMessage(Text::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk), 'error');
continue;
}
}
// Set the new category ID
$table->catid = $categoryId;
// Check the row.
if (!$table->check()) {
throw new Exception($table->getError(), 500);
return false;
}
// Store the row.
if (!$table->store()) {
throw new Exception($table->getError(), 500);
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
public function increaseOrdering($categoryId) {
$ordering = 1;
$this->_db->setQuery('SELECT MAX(ordering) FROM #__phocadownload WHERE catid='.(int)$categoryId);
$max = $this->_db->loadResult();
$ordering = $max + 1;
return $ordering;
}
/*
function copyQuick($cid) {
$table = $this->getTable();
foreach ($cid as $id) {
$table->load($id);
// Find last ordering
$this->_db->setQuery('SELECT MAX(ordering) FROM #__phocadownload WHERE catid='.(int)$table->catid);
$max = $this->_db->loadResult();
$table->ordering = $max+1;
// End Ordering
$table->id = null;
$table->hits = 0;
if ( !$table->check() ) {
throw new Exception($this->_db->getErrorMsg(), 500);
return false;
}
if ( !$table->store() ) {
throw new Exception($this->_db->getErrorMsg(), 500);
return false;
}
}
return true;
}*/
}
?>

View File

@ -0,0 +1,228 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined( '_JEXEC' ) or die();
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\Utilities\ArrayHelper;
jimport( 'joomla.application.component.modellist' );
jimport( 'joomla.filesystem.folder' );
jimport( 'joomla.filesystem.file' );
class PhocaDownloadCpModelPhocaDownloadFiles extends ListModel
{
protected $option = 'com_phocadownload';
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'alias', 'a.alias',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'category_id', 'category_id',
'state', 'a.state',
'access', 'a.access', 'access_level',
'ordering', 'a.ordering',
'language', 'a.language',
'date', 'a.date',
'hits', 'a.hits',
'average', 'v.average',
'published','a.published',
'filename', 'a.filename',
'autorized', 'a.approved',
'uploadusername', 'uploadusername',
'owner_id', 'a.owner_id'
);
}
parent::__construct($config);
}
protected function populateState($ordering = 'a.title', $direction = 'ASC')
{
// Initialise variables.
$app = Factory::getApplication('administrator');
// Load the filter state.
$search = $app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int');
$this->setState('filter.access', $accessId);
$state = $app->getUserStateFromRequest($this->context.'.filter.published', 'filter_published', '', 'string');
$this->setState('filter.published', $state);
$categoryId = $app->getUserStateFromRequest($this->context.'.filter.category_id', 'filter_category_id', null);
$this->setState('filter.category_id', $categoryId);
$language = $app->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
// Load the parameters.
$params = ComponentHelper::getParams('com_phocadownload');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.search');
$id .= ':'.$this->getState('filter.access');
$id .= ':'.$this->getState('filter.published');
//$id .= ':'.$this->getState('filter.category_id');
$id .= ':' . serialize($this->getState('filter.category_id'));
$id .= ':'.$this->getState('filter.image_id');
return parent::getStoreId($id);
}
protected function getListQuery()
{
/*
SELECT a.*, cc.title AS categorytitle, s.title AS sectiontitle, u.name AS editor, g.name AS groupname, us.id AS ownerid, us.username AS ownername '
. ' FROM #__phocadownload AS a '
. ' LEFT JOIN #__phocadownload_categories AS cc ON cc.id = a.catid'
. ' LEFT JOIN #__phocadownload_sections AS s ON s.id = a.sectionid'
. ' LEFT JOIN #__groups AS g ON g.id = a.access'
. ' LEFT JOIN #__users AS u ON u.id = a.checked_out'
. ' LEFT JOIN #__users AS us ON us.id = a.owner_id'
*/
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from('`#__phocadownload` AS a');
// Join over the language
$query->select('l.title AS language_title');
$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
$query->select('uua.id AS uploaduserid, uua.username AS uploadusername, uua.name AS uploadname');
$query->join('LEFT', '#__users AS uua ON uua.id=a.userid');
// Join over the asset groups.
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Join over the categories.
$query->select('c.title AS category_title, c.id AS category_id');
$query->join('LEFT', '#__phocadownload_categories AS c ON c.id = a.catid');
$query->select('ua.id AS userid, ua.username AS username, ua.name AS usernameno');
$query->join('LEFT', '#__users AS ua ON ua.id = a.owner_id');
//$query->select('v.average AS ratingavg');
//$query->join('LEFT', '#__phocadownload_img_votes_statistics AS v ON v.imgid = a.id');
// Filter by access level.
if ($access = $this->getState('filter.access')) {
$query->where('a.access = '.(int) $access);
}
// Filter by published state.
$published = $this->getState('filter.published');
if (is_numeric($published)) {
$query->where('a.published = '.(int) $published);
}
else if ($published === '') {
$query->where('(a.published IN (0, 1))');
}
// Filter by category.
//$categoryId = $this->getState('filter.category_id');
$categoryId = $this->getState('filter.category_id', []);
if (!\is_array($categoryId)) {
$categoryId = $categoryId ? [$categoryId] : [];
}
/*if (is_numeric($categoryId)) {
$query->where('a.catid = ' . (int) $categoryId);
}*/
if (\count($categoryId)) {
$categoryId = ArrayHelper::toInteger($categoryId);
$subCatItemsWhere = [];
foreach ($categoryId as $k => $v) {
$categoryWhere = 'a.catid = ' . (int) $v;
$subCatItemsWhere[] = '(' . $categoryWhere . ')';
}
$query->where('(' . implode(' OR ', $subCatItemsWhere) . ')');
}
// Filter on the language.
if ($language = $this->getState('filter.language')) {
$query->where('a.language = ' . $db->quote($language));
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
}
else
{
$search = $db->Quote('%'.$db->escape($search, true).'%');
$query->where('( a.title LIKE '.$search.' OR a.filename LIKE '.$search.')');
}
}
//$query->group('a.id, a.catid, a.sectionid, a.sid, a.owner_id, a.title, a.alias, a.filename, a.filename_play, a.filename_preview, a.filesize, a.author, a.author_email');
// Add the list ordering clause.
//$orderCol = $this->state->get('list.ordering');
//$orderDirn = $this->state->get('list.direction');
$orderCol = $this->state->get('list.ordering', 'title');
$orderDirn = $this->state->get('list.direction', 'asc');
if ($orderCol == 'a.ordering' || $orderCol == 'category_title') {
$orderCol = 'category_title '.$orderDirn.', a.ordering';
}
$query->order($db->escape($orderCol.' '.$orderDirn));
//echo nl2br(str_replace('#__', 'jos_', $query->__toString()));
return $query;
}
public function getNotApprovedFile() {
$query = 'SELECT COUNT(a.id) AS count'
.' FROM #__phocadownload AS a'
.' WHERE approved = 0';
$this->_db->setQuery($query, 0, 1);
$countNotApproved = $this->_db->loadObject();
return $countNotApproved;
}
}
?>

View File

@ -0,0 +1,53 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined( '_JEXEC' ) or die();
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Factory;
jimport('joomla.application.component.modeladmin');
class PhocaDownloadCpModelPhocaDownloadLayout extends AdminModel
{
protected $option = 'com_phocadownload';
protected $text_prefix = 'com_phocadownload';
public $typeAlias = 'com_phocadownload.phocadownloadlayout';
public function getTable($type = 'PhocaDownloadLayout', $prefix = 'Table', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
public function getForm($data = array(), $loadData = true) {
$app = Factory::getApplication();
$form = $this->loadForm('com_phocadownload.phocadownloadlayout', 'phocadownloadlayout', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_phocadownload.edit.phocadownloadlayout.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
}
?>

View File

@ -0,0 +1,97 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined( '_JEXEC' ) or die();
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\ApplicationHelper;
jimport('joomla.application.component.modeladmin');
class PhocaDownloadCpModelPhocaDownloadLic extends AdminModel
{
protected $option = 'com_phocadownload';
protected $text_prefix = 'com_phocadownload';
public $typeAlias = 'com_phocadownload.phocadownloadlic';
protected function canDelete($record)
{
//$user = JFactory::getUser();
return parent::canDelete($record);
}
protected function canEditState($record)
{
//$user = JFactory::getUser();
return parent::canEditState($record);
}
public function getTable($type = 'PhocaDownloadLic', $prefix = 'Table', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
public function getForm($data = array(), $loadData = true) {
$app = Factory::getApplication();
$form = $this->loadForm('com_phocadownload.phocadownloadlic', 'phocadownloadlic', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_phocadownload.edit.phocadownloadlic.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
protected function prepareTable($table)
{
jimport('joomla.filter.output');
$date = Factory::getDate();
$user = Factory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = ApplicationHelper::stringURLSafe($table->alias);
if (empty($table->alias)) {
$table->alias = ApplicationHelper::stringURLSafe($table->title);
}
if (empty($table->id)) {
// Set the values
//$table->created = $date->toSql();
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = Factory::getDbo();
$db->setQuery('SELECT MAX(ordering) FROM #__phocadownload_licenses');
$max = $db->loadResult();
$table->ordering = $max+1;
}
}
else {
// Set the values
//$table->modified = $date->toSql();
//$table->modified_by = $user->get('id');
}
}
}
?>

View File

@ -0,0 +1,157 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined( '_JEXEC' ) or die();
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
jimport('joomla.application.component.modellist');
class PhocaDownloadCpModelPhocaDownloadLics extends ListModel
{
protected $option = 'com_phocadownload';
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'alias', 'a.alias',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'state', 'a.state',
'ordering', 'a.ordering',
'language', 'a.language',
'hits', 'a.hits',
'published','a.published',
);
}
parent::__construct($config);
}
protected function populateState($ordering = 'a.title', $direction = 'ASC')
{
// Initialise variables.
$app = Factory::getApplication('administrator');
// Load the filter state.
$search = $app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
/* $accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int');
$this->setState('filter.access', $accessId);*/
$state = $app->getUserStateFromRequest($this->context.'.filter.published', 'filter_published', '', 'string');
$this->setState('filter.published', $state);
$language = $app->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
// Load the parameters.
$params = ComponentHelper::getParams('com_phocadownload');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.search');
//$id .= ':'.$this->getState('filter.access');
$id .= ':'.$this->getState('filter.published');
$id .= ':'.$this->getState('filter.lic_id');
return parent::getStoreId($id);
}
protected function getListQuery()
{
/*
$query = ' SELECT a.*, u.name AS editor '
. ' FROM #__phocadownload_licenses AS a '
. ' LEFT JOIN #__users AS u ON u.id = a.checked_out '
*/
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from('`#__phocadownload_licenses` AS a');
// Join over the language
$query->select('l.title AS language_title');
$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Filter by access level.
/* if ($access = $this->getState('filter.access')) {
$query->where('a.access = '.(int) $access);
}*/
// Filter by published state.
$published = $this->getState('filter.published');
if (is_numeric($published)) {
$query->where('a.published = '.(int) $published);
}
else if ($published === '') {
$query->where('(a.published IN (0, 1))');
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
}
else
{
$search = $db->Quote('%'.$db->escape($search, true).'%');
$query->where('( a.title LIKE '.$search.' OR a.alias LIKE '.$search.')');
}
}
//$orderCol = $this->state->get('list.ordering');
//$orderDirn = $this->state->get('list.direction');
$orderCol = $this->state->get('list.ordering', 'title');
$orderDirn = $this->state->get('list.direction', 'asc');
$query->order($db->escape($orderCol.' '.$orderDirn));
//echo nl2br(str_replace('#__', 'jos_', $query->__toString()));
return $query;
}
}
?>

View File

@ -0,0 +1,82 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined('_JEXEC') or die();
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
jimport('joomla.application.component.model');
class PhocaDownloadCpModelPhocaDownloadLinkCat extends BaseDatabaseModel
{
//var $_data_sec;
var $_data_cat;
function __construct() {
parent::__construct();
}
/*
function &getDataSec() {
if ($this->_loadDataSec()) {
} else {
$this->_initDataSec();
}
return $this->_data_sec;
}*/
function &getDataCat($sectionList) {
if ($this->_loadDataCat($sectionList)) {
} else {
$this->_initDataCat();
}
return $this->_data_cat;
}
/*
function _loadDataSec() {
if (empty($this->_data_sec)) {
$query = 'SELECT s.id, s.title'
. ' FROM #__phocadownload_sections AS s'
. ' WHERE s.published = 1'
. ' ORDER BY s.ordering';
$this->_db->setQuery($query);
$this->_data_sec = $this->_db->loadObjectList();
return (boolean) $this->_data_sec;
}
return true;
}*/
/*
function _loadDataCat($sectionList) {
if (empty($this->_data_cat)) {
$query = 'SELECT c.id, c.title, c.section'
.' FROM #__phocadownload_categories AS c'
.' WHERE c.section IN ( \''.$sectionList.'\' )'
.' AND c.published = 1'
.' ORDER BY c.ordering';
$this->_db->setQuery($query);
$this->_data_cat = $this->_db->loadObjectList();
return (boolean) $this->_data_cat;
}
return true;
}*/
/*
function _initDataSec() {
if (empty($this->_data_sec)) {
return (boolean) array();
}
return true;
}*/
function _initDataCat() {
if (empty($this->_data_cat)) {
return (boolean) array();
}
return true;
}
}
?>

View File

@ -0,0 +1,128 @@
<?php
/*
* @package Joomla 1.5
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('_JEXEC') or die();
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Pagination\Pagination;
jimport('joomla.application.component.model');
use Joomla\String\StringHelper;
class PhocaDownloadCpModelPhocaDownloadLinkFile extends BaseDatabaseModel
{
var $_data = null;
var $_total = null;
var $_pagination = null;
var $_context = 'com_phocadownload.phocadownloadlinkfile';
function __construct() {
parent::__construct();
$app = Factory::getApplication();
// Get the pagination request variables
$limit = $app->getUserStateFromRequest( $this->_context.'.list.limit', 'limit', $app->get('list_limit'), 'int' );
$limitstart = $app->getUserStateFromRequest( $this->_context.'.limitstart', 'limitstart', 0, 'int' );
// In case limit has been changed, adjust limitstart accordingly
$limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
function getData() {
if (empty($this->_data)) {
$query = $this->_buildQuery();
$this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit'));
}
return $this->_data;
}
function getTotal() {
if (empty($this->_total)) {
$query = $this->_buildQuery();
$this->_total = $this->_getListCount($query);
}
return $this->_total;
}
function getPagination() {
if (empty($this->_pagination)) {
jimport('joomla.html.pagination');
$this->_pagination = new Pagination( $this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
}
return $this->_pagination;
}
function _buildQuery() {
$where = $this->_buildContentWhere();
$orderby = $this->_buildContentOrderBy();
$query = ' SELECT a.*, cc.title AS categorytitle, ag.title AS access_level '
. ' FROM #__phocadownload AS a '
. ' LEFT JOIN #__phocadownload_categories AS cc ON cc.id = a.catid '
//. ' LEFT JOIN #__phocadownload_sections AS s ON s.id = a.sectionid '
. ' LEFT JOIN #__viewlevels AS ag ON ag.id = a.access '
. ' LEFT JOIN #__users AS u ON u.id = a.checked_out '
. $where
. $orderby
;
return $query;
}
function _buildContentOrderBy() {
$app = Factory::getApplication();
$filter_order = $app->getUserStateFromRequest( $this->_context.'.filter_order', 'filter_order', 'a.ordering','cmd' );
$filter_order_Dir = $app->getUserStateFromRequest( $this->_context.'.filter_order_Dir', 'filter_order_Dir', '', 'word' );
if ($filter_order == 'a.ordering'){
$orderby = ' ORDER BY categorytitle, a.ordering '.$filter_order_Dir;
} else {
$orderby = ' ORDER BY '.$filter_order.' '.$filter_order_Dir.', categorytitle, a.ordering ';
}
return $orderby;
}
function _buildContentWhere() {
$app = Factory::getApplication();
$filter_published = $app->getUserStateFromRequest( $this->_context.'.filter_published', 'filter_published', '', 'word' );
$filter_catid = $app->getUserStateFromRequest( $this->_context.'.catid','catid',0, 'int' );
//$filter_sectionid = $app->getUserStateFromRequest( $this->_context.'.filter_sectionid', 'filter_sectionid', 0, 'int' );
$filter_order = $app->getUserStateFromRequest( $this->_context.'.filter_order', 'filter_order', 'a.ordering', 'cmd' );
$filter_order_Dir = $app->getUserStateFromRequest( $this->_context.'.filter_order_Dir', 'filter_order_Dir', '', 'word' );
$search = $app->getUserStateFromRequest( $this->_context.'.search','search','','string' );
//$search = J String::strtolower( $search );
$search = StringHelper::strtolower( $search );
$where = array();
if ($filter_catid > 0) {
$where[] = 'a.catid = '.(int) $filter_catid;
}
if ($search) {
$where[] = 'LOWER(a.title) LIKE '.$this->_db->Quote('%'.$search.'%');
}
if ( $filter_published ) {
if ( $filter_published == 'P' ) {
$where[] = 'a.published = 1';
} else if ($filter_published == 'U' ) {
$where[] = 'a.published = 0';
}
}
$where[] = 'a.published = 1';
$where[] = 'a.approved = 1';
$where[] = 'a.textonly <> 1';
$where = ( count( $where ) ? ' WHERE '. implode( ' AND ', $where ) : '' );
return $where;
}
}
?>

View File

@ -0,0 +1,29 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('_JEXEC') or die();
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
jimport('joomla.application.component.model');
class PhocaDownloadCpModelPhocaDownloadLog extends BaseDatabaseModel
{
function __construct() {
parent::__construct();
}
function reset() {
//$user = JFactory::getUser();
$query = 'TRUNCATE #__phocadownload_logging';
$this->_db->setQuery( $query );
if (!$this->_db->execute()) {
throw new Exception($this->_db->getError());
return false;
}
return true;
}
}
?>

View File

@ -0,0 +1,197 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('_JEXEC') or die();
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
jimport('joomla.application.component.modellist');
jimport( 'joomla.filesystem.folder' );
jimport( 'joomla.filesystem.file' );
class PhocaDownloadCpModelPhocaDownloadLogs extends ListModel
{
protected $option = 'com_phocadownload';
public $context = 'com_phocadownload.phocadownloadlogs';
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'a.id',
'date', 'a.date',
'username', 'ua.username',
'category_id', 'category_id',
'file_id', 'f.id',
'file_title', 'f.title',
'filename', 'f.filename',
'ip', 'a.ip',
'page', 'a.page',
'type', 'a.type'
);
}
parent::__construct($config);
}
protected function populateState($ordering = 'a.date', $direction = 'ASC')
{
// Initialise variables.
$app = Factory::getApplication('administrator');
// Load the filter state.
$search = $app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
/*
$accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int');
$this->setState('filter.access', $accessId);
*/
//$state = $app->getUserStateFromRequest($this->context.'.filter.published', 'filter_published', '', 'string');
// $this->setState('filter.published', $state);
/*
$categoryId = $app->getUserStateFromRequest($this->context.'.filter.category_id', 'filter_category_id', null);
$this->setState('filter.category_id', $categoryId);
$language = $app->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
*/
$type = $app->getUserStateFromRequest($this->context.'.filter.type', 'filter_type', '', 'string');
$this->setState('filter.type', $type);
// Load the parameters.
$params = ComponentHelper::getParams('com_phocadownload');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.search');
$id .= ':'.$this->getState('filter.type');
//$id .= ':'.$this->getState('filter.access');
//$id .= ':'.$this->getState('filter.published');
return parent::getStoreId($id);
}
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from('#__phocadownload_logging AS a');
// Join over the language
//$query->select('l.title AS language_title');
//$query->join('LEFT', '#__languages AS l ON l.lang_code = a.language');
$query->select('f.id as file_id, f.title as file_title, f.filename as filename');
$query->join('LEFT', '#__phocadownload AS f ON f.id = a.fileid');
$query->select('cc.id as category_id');
$query->join('LEFT', '#__phocadownload_categories AS cc ON cc.id = f.catid');
// Join over the users for the checked out user.
//$query->select('ua.id AS userid, ua.username AS username, ua.name AS usernameno');
//$query->join('LEFT', '#__users AS ua ON ua.id=a.userid');
$query->select('ua.id AS userid, ua.username AS username, ua.name AS usernameno');
$query->join('LEFT', '#__users AS ua ON ua.id = a.userid');
//$query->select('uc.name AS editor');
//$query->join('LEFT', '#__users AS uc ON uc.id=f.checked_out');
/* // Join over the asset groups.
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
*/
// Filter by access level.
/* if ($access = $this->getState('filter.access')) {
$query->where('a.access = '.(int) $access);
}*/
// Filter by published state.
/*$published = $this->getState('filter.published');
if (is_numeric($published)) {
$query->where('a.published = '.(int) $published);
}
else if ($published === '') {
$query->where('(a.published IN (0, 1))');
}*/
// Filter by published type.
$type = $this->getState('filter.type');
if (is_numeric($type)) {
$query->where('a.type = '.(int) $type);
}
else if ($type === '') {
$query->where('(a.type IN (1, 2))');
}
// Filter by category.
/*$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId)) {
$query->where('a.catid = ' . (int) $categoryId);
}*/
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
}
else
{
$search = $db->Quote('%'.$db->escape($search, true).'%');
$query->where('( ua.username LIKE '.$search.' OR ua.name LIKE '.$search.' OR f.title LIKE '.$search.' OR f.filename LIKE '.$search.' or a.ip LIKE '.$search.')');
}
}
//$query->group('a.id');
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering', 'date');
$orderDirn = $this->state->get('list.direction', 'asc');
if ($orderCol == 'a.id' || $orderCol == 'username') {
$orderCol = 'username '.$orderDirn.', a.id';
}
$query->order($db->escape($orderCol.' '.$orderDirn));
//echo nl2br(str_replace('#__', 'jos_', $query->__toString()));
return $query;
}
}
?>

View File

@ -0,0 +1,590 @@
<?php
/*
* @package Joomla 1.5
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('_JEXEC') or die();
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Table\Table;
jimport('joomla.application.component.modeladmin');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
class PhocaDownloadCpModelPhocaDownloadM extends AdminModel
{
protected $option = 'com_phocadownload';
protected $text_prefix = 'com_phocadownload';
public $typeAlias = 'com_phocadownload.phocadownloadm';
protected $fileCount = 0;
protected $categoryCount = 0;
function __construct() {
$this->fileCount = 0;
$this->categoryCount = 0;
parent::__construct();
}
function setFileCount($count) {
$this->fileCount = $this->fileCount + $count;
}
function setCategoryCount($count) {
$this->categoryCount = $this->categoryCount + $count;
}
function save($data) {
$app = Factory::getApplication();
$foldercid = $app->input->get('foldercid', array(), 'raw');
$cid = $app->input->get('cid', 0, 'raw');
$data = $app->input->get('jform', array(0), 'post', 'array');
// =================================================
// Make a copy for play and preview
$paramsC = ComponentHelper::getParams('com_phocadownload') ;
$papCopy = $paramsC->get( 'pap_copy', 0 );
$data['pap_copy_m'] = 0;
if ($papCopy == 2 || $papCopy == 3) {
$data['pap_copy_m'] = 1;
}
// =================================================
if(isset($foldercid)) {
$data['foldercid'] = $foldercid;
}
if(isset($cid)) {
$data['cid'] = $cid;
}
if (isset($data['catid']) && (int)$data['catid'] > 0) {
$data['catid'] = (int)$data['catid'];
} else {
$data['catid'] = 0;
}
//Get folder variables from Helper
$path = PhocaDownloadPath::getPathSet();
$origPath = $path['orig_abs_ds'];
$origPathServer = str_replace('\\', '/', Path::clean($path['orig_abs_ds']));
// Cache all existing categories
$query = 'SELECT id, title, parent_id'
. ' FROM #__phocadownload_categories' ;
$this->_db->setQuery( $query );
$existingCategories = $this->_db->loadObjectList() ;
// Cache all existing files
$query = 'SELECT catid, filename'
. ' FROM #__phocadownload';
$this->_db->setQuery( $query );
$existingFiles = $this->_db->loadObjectList() ;
$result = new StdClass();
$result->category_count = 0;
$result->image_count = 0;
// Category will be saved - Files will be saved in recursive function
if (isset($data['foldercid'])) {
foreach ($data['foldercid'] as $foldername) {
if (strlen($foldername) > 0) {
$fullPath = $path['orig_abs_ds'].$foldername;
$result = $this->_createCategoriesRecursive( $origPathServer, $fullPath, $existingCategories, $existingFiles, $data['catid'], $data );
}
}
}
// Only Files will be saved
if (!empty($data['cid'])) {
// Make a copy for play and preview (1) --------
if (isset($data['pap_copy_m']) && $data['pap_copy_m'] == 1) {
//$paramsC = JComponentHelper::getParams('com_phocadownload') ;
$overwriteExistingFiles = $paramsC->get( 'overwrite_existing_files', 0 );
}
// ------------------------------------------------
foreach ($data['cid'] as $filename) {
if ($filename) {
//$ext = strtolower(JFile::getExt($filename));
$row = $this->getTable('phocadownload');
$datam = array();
$datam['published'] = $data['published'];
$datam['catid'] = $data['catid'];
$datam['approved'] = $data['approved'];
$datam['language'] = $data['language'];
$datam['filename'] = $filename;
if ($data['title'] != '') {
$datam['title'] = $data['title'];
} else {
$datam['title'] = PhocaDownloadFile::getTitleFromFilenameWithoutExt($filename);
}
if ($data['alias'] != '') {
$datam['alias'] = $data['alias'];
} else {
$datam['alias'] = $data['alias']; // PhocaDownloadFile::getAliasName($datam['title']);
}
$datam['token'] = PhocaDownloadUtils::getToken($datam['title'].$datam['filename']);
// Make a copy for play and preview (2)
if (isset($data['pap_copy_m']) && $data['pap_copy_m'] == 1) {
$filenameExt = PhocaDownloadFile::getTitleFromFilenameWithExt($filename);
$storedfilename = $filename;
$storedfoldername = str_replace($filenameExt, '', $storedfilename);
$o = $this->_copyPreviewAndPlay($filenameExt, $storedfilename, $storedfoldername, $path, $overwriteExistingFiles);
$datam['filename_play'] = $o['filename_play'];
$datam['filename_preview'] = $o['filename_preview'];
}
// Save
// Bind the form fields to the Phoca download table
if (!$row->bind($datam)) {
//throw new Exception($this->_db->getError());
$this->setError($row->getError());
return false;
}
// Create the timestamp for the date
//$row->date = gmdate('Y-m-d H:i:s');
$nullDate = $this->_db->getNullDate();
$date = Factory::getDate();
$row->date = $date->toSql();
if(intval($row->publish_up) == 0) {
$row->publish_up = $row->date;//Factory::getDate()->toSql();
}
// Handle never unpublish date
if (trim((string)$row->publish_down) == Text::_('Never') || trim( (string)$row->publish_down ) == '') {
$row->publish_down = $nullDate;
} else {
if (strlen(trim( $row->publish_down )) <= 10) {
$row->publish_down .= ' 00:00:00';
}
//$date = JFactory::getDate($row->publish_down, $tzoffset);
$date = Factory::getDate($row->publish_down);
$row->publish_down = $date->toSql();
}
// - - - - - -
// if new item, order last in appropriate group
if (!$row->id) {
$where = 'catid = ' . (int) $row->catid ;
$row->ordering = $row->getNextOrder( $where );
}
// Make sure the Phoca download table is valid
if (!$row->check()) {
//throw new Exception($this->_db->getError());
$this->setError($row->getError());
return false;
}
// Store the Phoca download table to the database
if (!$row->store()) {
//throw new Exception($this->_db->getError());
$this->setError($row->getError());
return false;
}
$result->image_count++;
}
}
$this->setfileCount($result->image_count);
}
$msg = $this->categoryCount. ' ' .Text::_('COM_PHOCADOWNLOAD_CATEGORIES_ADDED') .', '.$this->fileCount. ' ' . Text::_('COM_PHOCADOWNLOAD_FILES_ADDED');
$app->enqueueMessage($msg);
$app->redirect(Route::_('index.php?option=com_phocadownload&view=phocadownloadfiles', false));
return true;
}
protected function _createCategoriesRecursive(&$origPathServer, $path, &$existingCategories, &$existingFiles, $parentId = 0, $data = array() ) {
$totalresult = new StdClass();
$totalresult->files_count = 0 ;
$totalresult->category_count = 0 ;
$totalresult->image_count = 0 ;
$categoryName = basename($path);
$id = $this->_getCategoryId( $existingCategories, $categoryName, $parentId ) ;
$category = null;
// Full path: eg. "/home/www/joomla/files/categ/subcat/"
$fullPath = str_replace('\\', '/', Path::clean('/' . $path));
// Relative path eg "categ/subcat"
$relativePath = str_replace($origPathServer, '', $fullPath);
// Category doesn't exist
if ( $id == -1 ) {
$row = $this->getTable('phocadownloadcat');
$row->published = $data['published'];
// $row->approved = $data['approved'];
$row->language = $data['language'];
$row->parent_id = $parentId;
$row->title = $categoryName;
// Create the timestamp for the date
$row->date = gmdate('Y-m-d H:i:s');
// $row->alias = $row->title; //PhocaDownloadFile::getAliasName($categoryName);
//$row->userfolder = ltrim(str_replace('\\', '/', JPath::clean($relativePath )), '/');
$row->ordering = $row->getNextOrder( "parent_id = " . $this->_db->Quote($row->parent_id) );
if (!$row->check()) {
throw new Exception($row->getError('Check Problem'), 500);
return false;
}
if (!$row->store()) {
throw new Exception($row->getError('Check Problem'), 500);
return false;
}
$category = new CMSObject();
$category->title = $categoryName ;
$category->parent_id = $parentId;
$category->id = $row->id;
$totalresult->category_count++;
$id = $category->id;
$existingCategories[] = &$category ;
$this->setCategoryCount(1);//This subcategory was added
}
// Add all files from this folder
$totalresult->image_count += $this->_addAllFilesFromFolder( $existingFiles, $id, $path, $relativePath, $data );
$this->setfileCount($totalresult->image_count);
// Do sub folders
$parentId = $id;
$folderList = Folder::folders( $path, $filter = '.', $recurse = false, $fullpath = true, $exclude = array() );
// Iterate over the folders if they exist
if ($folderList !== false) {
foreach ($folderList as $folder) {
//$this->setCategoryCount(1);//This subcategory was added
$folderName = $relativePath .'/' . str_replace($origPathServer, '', $folder);
$result = $this->_createCategoriesRecursive( $origPathServer, $folder, $existingCategories, $existingFiles, $id , $data);
$totalresult->image_count += $result->image_count ;
$totalresult->category_count += $result->category_count ;
}
}
return $totalresult ;
}
protected function _getCategoryId( &$existingCategories, &$title, $parentId ) {
$id = -1;
$i = 0;
$count = count($existingCategories);
while ( $id == -1 && $i < $count ) {
if ( $existingCategories[$i]->title == $title &&
$existingCategories[$i]->parent_id == $parentId ) {
$id = $existingCategories[$i]->id ;
}
$i++;
}
return $id;
}
protected function _FileExist( &$existing_image, &$filename, $catid ) {
$result = false ;
$i = 0;
$count = count($existing_image);
while ( $result == false && $i < $count ) {
if ( $existing_image[$i]->filename == $filename &&
$existing_image[$i]->catid == $catid ) {
$result = true;
}
$i++;
}
return $result;
}
protected function _addAllFilesFromFolder(&$existingImages, $category_id, $fullPath, $rel_path, $data = array()) {
$count = 0;
$fileList = Folder::files( $fullPath );
natcasesort($fileList);
// Iterate over the files if they exist
//file - abc.img, file_no - folder/abc.img
// Make a copy for play and preview (1) --------
if (isset($data['pap_copy_m']) && $data['pap_copy_m'] == 1) {
$path = PhocaDownloadPath::getPathSet();
$storedfoldername = ltrim(str_replace('\\', '/', Path::clean($rel_path )), '/');
$paramsC = ComponentHelper::getParams('com_phocadownload') ;
$overwriteExistingFiles = $paramsC->get( 'overwrite_existing_files', 0 );
}
// ------------------------------------------------
if ($fileList !== false) {
foreach ($fileList as $filename) {
$storedfilename = ltrim(str_replace('\\', '/', Path::clean($rel_path . '/' . $filename )), '/');
//$ext = strtolower(JFile::getExt($filename));
if (File::exists($fullPath.'/'.$filename) &&
substr($filename, 0, 1) != '.' &&
strtolower($filename) !== 'index.html' &&
!$this->_FileExist($existingImages, $storedfilename, $category_id) ) {
$row = $this->getTable('phocadownload');
$datam = array();
$datam['published'] = $data['published'];
$datam['catid'] = $category_id;
$datam['filename'] = $storedfilename;
$datam['approved'] = $data['approved'];
$datam['language'] = $data['language'];
// Default values
if (!isset($data['publish_up']) || $data['publish_up'] == '0' || $data['publish_up'] == '') {
$datam['publish_up'] = '0000-00-00 00:00:00';
} else {
$datam['publish_up'] = $data['publish_up'];
}
if (!isset($data['publish_down']) || $data['publish_down'] == '0' || $data['publish_down'] == '') {
$datam['publish_down'] = '0000-00-00 00:00:00';
} else {
$datam['publish_down'] = $data['publish_down'];
}
if ($data['title'] != '') {
$datam['title'] = $data['title'];
} else {
$datam['title'] = PhocaDownloadFile::getTitleFromFilenameWithoutExt($filename);
}
if ($data['alias'] != '') {
$datam['alias'] = $data['alias'];
} else {
$datam['alias'] = $data['alias'];//PhocaDownloadFile::get AliasName($datam['title']);
}
$datam['token'] = PhocaDownloadUtils::getToken($datam['title'].$datam['filename']);
$image = new CMSObject();
// Make a copy for play and preview (2)
if (isset($data['pap_copy_m']) && $data['pap_copy_m'] == 1) {
$o = $this->_copyPreviewAndPlay($filename, $storedfilename, $storedfoldername, $path, $overwriteExistingFiles);
$datam['filename_play'] = $o['filename_play'];
$datam['filename_preview'] = $o['filename_preview'];
}
// Save
// Bind the form fields to the Phoca download table
if (!$row->bind($datam)) {
//throw new Exception($this->_db->getError());
$this->setError($row->getError());
return false;
}
// Create the timestamp for the date
$row->date = gmdate('Y-m-d H:i:s');
// if new item, order last in appropriate group
if (!$row->id) {
$where = 'catid = ' . (int) $row->catid ;
$row->ordering = $row->getNextOrder( $where );
}
// Make sure the Phoca download table is valid
if (!$row->check()) {
//throw new Exception($this->_db->getError());
$this->setError($row->getError());
return false;
}
// Store the Phoca download table to the database
if (!$row->store()) {
//throw new Exception($this->_db->getError());
$this->setError($row->getError());
return false;
}
// --------------------------------------------
/*if ($this->firstImageFolder == '') {
$this->setFirstImageFolder($row->filename);
}*/
$image->filename = $storedfilename;
$image->catid = $category_id;
$existingImages[] = &$image ;
$count++ ;
}
}
}
// $this->setfileCount($count);
return $count;
}
protected function _copyPreviewAndPlay($filename, $storedfilename, $storedfoldername, $path, $overwriteExistingFiles) {
$o['filename_play'] = '';
$o['filename_preview'] = '';
$canPlay = PhocaDownloadFile::canPlay($filename);
$canPreview = PhocaDownloadFile::canPreview($filename);
$filepathPAP = Path::clean($path['orig_abs_pap_ds']. $storedfilename);
//$filepathUserFolderPAP = JPath::clean($path['orig_abs_pap_ds']. $storedfoldername);
$filepath = Path::clean($path['orig_abs_ds']. $storedfilename);
$filepathPAPFolder = Path::clean($path['orig_abs_pap_ds'] . '/'. PhocaDownloadFile::getFolderFromTheFile($storedfilename));
if ($canPlay || $canPreview) {
// 1. UPLOAD - this is real upload to folder
// 2. STORE - this is storing info to database (e.g. download and play/preview files are identical, then there will be no copy of the file but only storing DB info
$uploadPAP = 1;// upload file for preview and play
$storePAP = 0;
// 1. Care about upload
if (File::exists($filepathPAP) && $overwriteExistingFiles == 0) {
//$errUploadMsg = JText::_("COM_PHOCADOWNLOAD_FILE_ALREADY_EXISTS");
//return false;
$uploadPAP = 0; // don't upload if it exists, it is not main file, don't do false and exit
}
// Overwrite file and add no new item to database
$fileExistsPAP = 0;
if (File::exists($filepathPAP) && $overwriteExistingFiles == 1) {
$fileExistsPAP = 1;
if ($canPlay == 1) {
// set new file only no other is set or it is the same like currect - to overwrite updated version of the same file
if ($o['filename_play'] == '' || $o['filename_play'] == $o['filename']) {
$o['filename_play'] = $storedfilename;
} else {
$uploadPAP = 0;
}
} else if ($canPreview == 1) {
// set new file only no other is set or it is the same like currect - to overwrite updated version of the same file
if ($o['filename_preview'] == '' || $o['filename_preview'] == $o['filename']) {
$o['filename_preview'] = $storedfilename;
} else {
$uploadPAP = 0;
}
}
}
if ($uploadPAP == 0) {
} else {
if (!Folder::exists($filepathPAPFolder)) {
if (Folder::create($filepathPAPFolder)) {
$dataFile = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
File::write($filepathPAPFolder . '/' ."index.html", $dataFile);
}
// else {
//$errUploadMsg = JText::_("COM_PHOCADOWNLOAD_UNABLE_TO_CREATE_FOLDER");
//return false;
//}
}
if ($filepath === $filepathPAP) {
// Don't try to copy the same file to the same file (including path) because you get error
$storePAP = 1;
} else if (!File::copy($filepath, $filepathPAP)) {
//$errUploadMsg = JText::_("COM_PHOCADOWNLOAD_UNABLE_TO_UPLOAD_FILE");
//return false;
} else {
$storePAP = 1;
}
}
// 2. Care about store
if ($filepath === $filepathPAP) {
// SPECIFIC CASE - administrator set the download folder the same like preview/play folder
// - in such case, there will be no copy because both files including path are identical
// - but we still write the info about play/preview into database
// - so no set uploadPAP to 0
$storePAP = 1;
}
if ($storePAP == 1) {
if ($canPlay == 1) {
$o['filename_play'] = $storedfilename;
} else if ($canPreview == 1) {
$o['filename_preview'] = $storedfilename;
}
}
}
return $o;
}
public function getForm($data = array(), $loadData = true) {
$form = $this->loadForm('com_phocadownload.phocadownloadmanager', 'phocadownloadmanager', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
public function getTable($type = 'PhocaDownload', $prefix = 'Table', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_phocadownloadm.edit.phocadownloadm.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
}
?>

View File

@ -0,0 +1,175 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('_JEXEC') or die();
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Filesystem\Path;
jimport('joomla.application.component.modeladmin');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
class PhocaDownloadCpModelPhocaDownloadManager extends AdminModel
{
protected $option = 'com_phocadownload';
protected $text_prefix = 'com_phocadownload';
public $typeAlias = 'com_phocadownload.phocadownloadmanager';
public function getTable($type = 'PhocaDownload', $prefix = 'Table', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
public function getForm($data = array(), $loadData = true) {
$form = $this->loadForm('com_phocadownload.phocadownloadmanager', 'phocadownloadmanager', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_phocadownloadm.edit.phocadownloadm.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
function getFolderState($property = null) {
static $set;
if (!$set) {
$folder = Factory::getApplication()->input->get( 'folder', '', '', 'path' );
$upload = Factory::getApplication()->input->get( 'upload', '', '', 'int' );
$manager = Factory::getApplication()->input->get( 'manager', '', '', 'path' );
$this->setState('folder', $folder);
$this->setState('manager', $manager);
$parent = str_replace("\\", "/", dirname($folder));
$parent = ($parent == '.') ? null : $parent;
$this->setState('parent', $parent);
$set = true;
}
return parent::getState($property);
}
function getFiles() {
$list = $this->getList();
return $list['files'];
}
function getFolders() {
$list = $this->getList();
return $list['folders'];
}
function getList() {
static $list;
//Params
$params = ComponentHelper::getParams( 'com_phocadownload' );
// Only process the list once per request
if (is_array($list)) {
return $list;
}
// Get current path from request
$current = $this->getState('folder');
// If undefined, set to empty
if ($current == 'undefined') {
$current = '';
}
// File Manager, Icon Manager
$manager = $this->getState('manager');
if ($manager == 'undefined') {
$manager = '';
}
$path = PhocaDownloadPath::getPathSet($manager);
$group = PhocaDownloadSettings::getManagerGroup($manager);
//$path = PhocaDownloadPath::getPathSet();
// Initialize variables
if (strlen($current) > 0) {
$orig_path = $path['orig_abs_ds'].$current;
} else {
$orig_path = $path['orig_abs_ds'];
}
$orig_path_server = str_replace('\\', '/', $path['orig_abs'] .'/');
// Absolute Path defined by user
$absolutePath = $params->get('absolute_path', '');
$absolutePath = str_replace('\\', '/', $absolutePath);
// Be aware - absolute path is not set for images folder and for preview and play folder - see documentation
if ($absolutePath != '' && $group['f'] == 1) {
$orig_path_server = str_replace('\\', '/', JPath::clean($absolutePath .'/') );//$absolutePath ;
}
$files = array ();
$folders = array ();
// Get the list of files and folders from the given folder
$file_list = Folder::files($orig_path);
$folder_list = Folder::folders($orig_path, '', false, false, array());
// Iterate over the files if they exist
//file - abc.img, file_no - folder/abc.img
if ($file_list !== false) {
foreach ($file_list as $file) {
if (is_file($orig_path.'/'.$file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') {
$tmp = new CMSObject();
$tmp->name = basename($file);
$tmp->path_with_name = str_replace('\\', '/', Path::clean($orig_path . '/' . $file));
$tmp->path_without_name_relative= $path['orig_rel_ds'] . str_replace($orig_path_server, '', $tmp->path_with_name);
$tmp->path_with_name = str_replace('\\', '/', Path::clean($orig_path . '/' . $file));
$tmp->path_with_name_relative_no= str_replace($orig_path_server, '', $tmp->path_with_name);
$files[] = $tmp;
}
}
}
// Iterate over the folders if they exist
if ($folder_list !== false) {
foreach ($folder_list as $folder)
{
$tmp = new CMSObject();
$tmp->name = basename($folder);
$tmp->path_with_name = str_replace('\\', '/', Path::clean($orig_path . '/' . $folder));
$tmp->path_without_name_relative= $path['orig_rel_ds'] . str_replace($orig_path_server, '', $tmp->path_with_name);
$tmp->path_with_name_relative_no= str_replace($orig_path_server, '', $tmp->path_with_name);
$folders[] = $tmp;
}
}
$list = array('folders' => $folders, 'files' => $files);
return $list;
}
}
?>

View File

@ -0,0 +1,261 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('_JEXEC') or die();
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Application\ApplicationHelper;
jimport('joomla.application.component.modellist');
class PhocaDownloadCpModelPhocaDownloadRaFile extends ListModel
{
protected $option = 'com_phocadownload';
public $typeAlias = 'com_phocadownload.phocadownloadrafile';
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'username','ua.username',
'date', 'a.date',
'alias', 'a.alias',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'category_id', 'category_id',
'state', 'a.state',
'ordering', 'a.ordering',
'language', 'a.language',
'hits', 'a.hits',
'published','a.published',
'rating', 'a.rating',
'file_title', 'file_title',
'category_title', 'category_title'
);
}
parent::__construct($config);
}
protected function populateState($ordering = 'ua.username', $direction = 'ASC')
{
// Initialise variables.
$app = Factory::getApplication('administrator');
// Load the filter state.
$search = $app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
/*
$accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int');
$this->setState('filter.access', $accessId);
$state = $app->getUserStateFromRequest($this->context.'.filter.published', 'filter_published', '', 'string');
$this->setState('filter.published', $state);
*/
$categoryId = $app->getUserStateFromRequest($this->context.'.filter.category_id', 'filter_category_id', null);
$this->setState('filter.category_id', $categoryId);
/*
$language = $app->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
*/
// Load the parameters.
$params = ComponentHelper::getParams('com_phocadownload');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.search');
//$id .= ':'.$this->getState('filter.access');
//$id .= ':'.$this->getState('filter.published');
$id .= ':'.$this->getState('filter.category_id');
return parent::getStoreId($id);
}
protected function getListQuery()
{
/*
$query = ' SELECT a.*, cc.title AS categorytitle, cc.id AS categoryid, i.title AS imagetitle, i.id AS imageid, ua.name AS editor, u.id AS ratinguserid, u.username AS ratingusername '
. ' FROM #__phocadownload_file_votes AS a '
. ' LEFT JOIN #__phocadownload AS i ON i.id = a.imgid '
. ' LEFT JOIN #__phocadownload_categories AS cc ON cc.id = i.catid '
. ' LEFT JOIN #__users AS ua ON ua.id = a.checked_out '
. ' LEFT JOIN #__users AS u ON u.id = a.userid'
. $where
. ' GROUP by a.id'
. $orderby;
*/
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from('`#__phocadownload_file_votes` AS a');
// Join over the language
$query->select('l.title AS language_title');
$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('ua.id AS ratinguserid, ua.username AS ratingusername, ua.name AS ratingname');
$query->join('LEFT', '#__users AS ua ON ua.id=a.userid');
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
$query->select('i.title AS file_title, i.id AS file_id');
$query->join('LEFT', '#__phocadownload AS i ON i.id = a.fileid');
/* // Join over the asset groups.
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
*/
// Join over the categories.
$query->select('c.title AS category_title, c.id AS category_id');
$query->join('LEFT', '#__phocadownload_categories AS c ON c.id = i.catid');
// Filter by access level.
/* if ($access = $this->getState('filter.access')) {
$query->where('a.access = '.(int) $access);
}*/
// Filter by published state.
$published = $this->getState('filter.published');
if (is_numeric($published)) {
$query->where('a.published = '.(int) $published);
}
else if ($published === '') {
$query->where('(a.published IN (0, 1))');
}
// Filter by category.
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId)) {
$query->where('i.catid = ' . (int) $categoryId);
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
}
else
{
$search = $db->Quote('%'.$db->escape($search, true).'%');
$query->where('( ua.name LIKE '.$search.' OR ua.username LIKE '.$search.')');
}
}
// $query->group('a.id');
// Add the list ordering clause.
//$orderCol = $this->state->get('list.ordering');
//$orderDirn = $this->state->get('list.direction');
$orderCol = $this->state->get('list.ordering', 'file_title');
$orderDirn = $this->state->get('list.direction', 'asc');
if ($orderCol == 'a.ordering' || $orderCol == 'category_title') {
$orderCol = 'category_title '.$orderDirn.', a.ordering';
}
$query->order($db->escape($orderCol.' '.$orderDirn));
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
}
function delete($cid = array()) {
if (count( $cid )) {
ArrayHelper::toInteger($cid);
$cids = implode( ',', $cid );
//Select affected catids
$query = 'SELECT v.fileid AS imgid'
. ' FROM #__phocadownload_file_votes AS v'
. ' WHERE v.id IN ( '.$cids.' )';
$images = $this->_getList($query);
//Delete it from DB
$query = 'DELETE FROM #__phocadownload_file_votes'
. ' WHERE id IN ( '.$cids.' )';
$this->_db->setQuery( $query );
if(!$this->_db->execute()) {
throw new Exception($this->_db->getError());
return false;
}
foreach ($images as $valueImgId) {
$updated = PhocaDownloadRate::updateVoteStatisticsFile( $valueImgId->imgid );
if(!$updated) {
return false;
}
}
}
return true;
}
protected function prepareTable(&$table)
{
jimport('joomla.filter.output');
$date = Factory::getDate();
$user = Factory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = ApplicationHelper::stringURLSafe($table->alias);
if (empty($table->alias)) {
$table->alias = ApplicationHelper::stringURLSafe($table->title);
}
if (empty($table->id)) {
// Set the values
//$table->created = $date->toSql();
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = Factory::getDbo();
$db->setQuery('SELECT MAX(ordering) FROM #__phocadownload_file_votes');
$max = $db->loadResult();
$table->ordering = $max+1;
}
}
else {
// Set the values
//$table->modified = $date->toSql();
//$table->modified_by = $user->get('id');
}
}
public function saveorder($pks, $order) {
return true;
}
}
?>

View File

@ -0,0 +1,251 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined( '_JEXEC' ) or die();
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
jimport( 'joomla.application.component.modellist' );
jimport( 'joomla.filesystem.folder' );
jimport( 'joomla.filesystem.file' );
class PhocaDownloadCpModelPhocaDownloadstat extends ListModel
{
protected $option = 'com_phocadownload';
public $typeAlias = 'com_phocadownload.phocadownloadstat';
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'a.id',
'hits', 'a.hits',
'filename', 'a.filename',
'title', 'a.title',
);
}
parent::__construct($config);
}
protected function populateState($ordering = 'a.hits', $direction = 'DESC')
{
// Initialise variables.
$app = Factory::getApplication('administrator');
// Load the filter state.
$search = $app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$state = $app->getUserStateFromRequest($this->context.'.filter.published', 'filter_published', '', 'string');
$this->setState('filter.published', $state);
$categoryId = $app->getUserStateFromRequest($this->context.'.filter.category_id', 'filter_category_id', null);
$this->setState('filter.category_id', $categoryId);
// Load the parameters.
$params = ComponentHelper::getParams('com_phocadownload');
$this->setState('params', $params);
// List state information.
//parent::populateState('uc.name', 'asc');
parent::populateState($ordering, $direction);
}
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.search');
$id .= ':'.$this->getState('filter.access');
$id .= ':'.$this->getState('filter.published');
$id .= ':'.$this->getState('filter.category_id');
$id .= ':'.$this->getState('filter.file_id');
return parent::getStoreId($id);
}
protected function getListQuery()
{
/*
$query = ' SELECT a.*, cc.title AS categorytitle, s.title AS sectiontitle, u.name AS editor, g.name AS groupname, MAX(a.hits) AS maxhit '
. ' FROM #__phocadownload AS a '
. ' LEFT JOIN #__phocadownload_categories AS cc ON cc.id = a.catid '
. ' LEFT JOIN #__phocadownload_sections AS s ON s.id = a.sectionid '
. ' LEFT JOIN #__groups AS g ON g.id = a.access '
. ' LEFT JOIN #__users AS u ON u.id = a.checked_out '
. $where
. ' GROUP by a.id'
. $orderby
*/
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from('`#__phocadownload` AS a');
// Join over the language
//$query->select('l.title AS language_title');
//$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Join over the asset groups.
//$query->select('ag.title AS access_level');
//$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Join over the categories.
$query->select('c.title AS category_title, c.id AS category_id');
$query->join('LEFT', '#__phocadownload_categories AS c ON c.id = a.catid');
//$query->select('ua.id AS userid, ua.username AS username, ua.name AS usernameno');
//$query->join('LEFT', '#__users AS ua ON ua.id = a.owner_id');
//$query->select('v.average AS ratingavg');
//$query->join('LEFT', '#__phocadownload_img_votes_statistics AS v ON v.imgid = a.id');
// Filter by access level.
//if ($access = $this->getState('filter.access')) {
// $query->where('a.access = '.(int) $access);
//}
// Filter by published state.
$published = $this->getState('filter.published');
if (is_numeric($published)) {
$query->where('a.published = '.(int) $published);
}
else if ($published === '') {
$query->where('(a.published IN (0, 1))');
}
// Filter by category.
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId)) {
$query->where('a.catid = ' . (int) $categoryId);
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
}
else
{
$search = $db->Quote('%'.$db->escape($search, true).'%');
$query->where('( a.title LIKE '.$search.' OR a.filename LIKE '.$search.')');
}
}
//$query->group('a.id');
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
if ($orderCol == 'a.ordering' || $orderCol == 'category_title') {
$orderCol = 'category_title '.$orderDirn.', a.ordering';
}
$query->order($db->escape($orderCol.' '.$orderDirn));
//echo nl2br(str_replace('#__', 'jos_', $query->__toString()));
return $query;
}
function getMaxAndSum() {
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->select(
$this->getState(
'list.select',
'MAX(a.hits) AS maxhit, SUM(a.hits) AS sumhit'
)
);
$query->from('`#__phocadownload` AS a');
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
//$query->select('c.title AS category_title, c.id AS category_id');
//$query->join('LEFT', '#__phocadownload_categories AS c ON c.id = a.catid');
// Filter by published state.
$published = $this->getState('filter.published');
if (is_numeric($published)) {
$query->where('a.published = '.(int) $published);
}
else if ($published === '') {
$query->where('(a.published IN (0, 1))');
}
// Filter by category.
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId)) {
$query->where('a.catid = ' . (int) $categoryId);
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
}
else
{
$search = $db->Quote('%'.$db->escape($search, true).'%');
$query->where('a.title LIKE '.$search.' OR a.filename LIKE '.$search);
}
}
$query->group('a.id, uc.name');
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
if ($orderCol == 'a.ordering' || $orderCol == 'category_title') {
$orderCol = 'category_title '.$orderDirn.', a.ordering';
}
$query->order($db->escape($orderCol.' '.$orderDirn));
$db->setQuery($query, 0, 1);
$maxAndSum = $db->loadObject();
//echo nl2br(str_replace('#__', 'jos_', $query->__toString()));
return $maxAndSum;
}
}
?>

View File

@ -0,0 +1,291 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined( '_JEXEC' ) or die();
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Log\Log;
jimport('joomla.application.component.modeladmin');
class PhocaDownloadCpModelPhocaDownloadStyle extends AdminModel
{
protected $option = 'com_phocadownload';
protected $text_prefix = 'com_phocadownload';
public $typeAlias = 'com_phocadownload.phocadownloadstyle';
protected function canDelete($record)
{
//$user = JFactory::getUser();
return parent::canDelete($record);
}
protected function canEditState($record)
{
//$user = JFactory::getUser();
return parent::canEditState($record);
}
public function getTable($type = 'PhocaDownloadStyle', $prefix = 'Table', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
public function getForm($data = array(), $loadData = true) {
$app = Factory::getApplication();
$form = $this->loadForm('com_phocadownload.phocadownloadstyles', 'phocadownloadstyle', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_phocadownload.edit.phocadownloadstyles.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
protected function prepareTable($table)
{
jimport('joomla.filter.output');
$date = Factory::getDate();
$user = Factory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = ApplicationHelper::stringURLSafe($table->alias);
if (empty($table->alias)) {
$table->alias = ApplicationHelper::stringURLSafe($table->title);
}
if (empty($table->id)) {
// Set the values
//$table->created = $date->toSql();
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = Factory::getDbo();
$db->setQuery('SELECT MAX(ordering) FROM #__phocadownload_styles WHERE type = '.(int)$table->type);
$max = $db->loadResult();
$table->ordering = $max+1;
}
}
else {
// Set the values
//$table->modified = $date->toSql();
//$table->modified_by = $user->get('id');
}
}
protected function getReorderConditions($table = null)
{
$condition = array();
$condition[] = 'type = '. (int) $table->type;
//$condition[] = 'state >= 0';
return $condition;
}
public function increaseOrdering($categoryId) {
$ordering = 1;
$this->_db->setQuery('SELECT MAX(ordering) FROM #__phocadownload_styles WHERE type='.(int)$categoryId);
$max = $this->_db->loadResult();
$ordering = $max + 1;
return $ordering;
}
public function &getSource($id, $filename, $type) {
$item = new stdClass;
$filePath = PhocaDownloadFile::existsCSS($filename, $type);
if ($filePath) {
//$item->id = $id;
//$item->type = $type;
//$item->filname = $filename;
$item->source = file_get_contents($filePath);
} else {
throw new Exception(Text::_('COM_PHOCADOWNLOAD_FILE_DOES_NOT_EXIST'), 500);
}
return $item;
}
public function save($data) {
jimport('joomla.filesystem.file');
// New
if ($data['id'] < 1) {
$data['type'] = 2;// Custom in every case
if ($data['title'] != '') {
$filename = ApplicationHelper::stringURLSafe($data['title']);
if (trim(str_replace('-','',$filename)) == '') {
$filename = Factory::getDate()->toFormat("%Y-%m-%d-%H-%M-%S");
}
} else {
$filename = Factory::getDate()->toFormat("%Y-%m-%d-%H-%M-%S");
}
$filename = $filename . '.css';
$data['filename'] = $filename;
$filePath = PhocaDownloadFile::existsCSS($filename, $data['type']);
if ($filePath) {
throw new Exception(Text::sprintf('COM_PHOCADOWNLOAD_FILE_ALREADY_EXISTS', $fileName), 500);
return false;
} else {
$filePath = PhocaDownloadFile::getCSSPath($data['type']) . $filename;
}
} else {
$filename = PhocaDownloadFile::getCSSFile($data['id']);
$filePath = PhocaDownloadFile::existsCSS($filename, $data['type']);
}
//$dispatcher = JEventDispatcher::getInstance();
$fileName = $filename;
// Include the extension plugins for the save events.
//JPluginHelper::importPlugin('extension');
// Set FTP credentials, if given.
ClientHelper::setCredentialsFromRequest('ftp');
$ftp = ClientHelper::getCredentials('ftp');
// Try to make the template file writeable.
if (!$ftp['enabled'] && Path::isOwner($filePath) && !Path::setPermissions($filePath, '0644')) {
throw new Exception(Text::_('COM_PHOCADOWNLOAD_ERROR_SOURCE_FILE_NOT_WRITABLE'), 500);
return false;
}
// Trigger the onExtensionBeforeSave event.
/*$result = $dispatcher->trigger('onExtensionBeforeSave', array('com_phocadownload.source', &$data, false));
if (in_array(false, $result, true)) {
throw new Exception($table->getError(), 500);
return false;
}*/
$return = File::write($filePath, $data['source']);
// Try to make the template file unwriteable.
if (!$return) {
throw new Exception(Text::sprintf('COM_PHOCADOWNLOAD_ERROR_FAILED_TO_SAVE_FILENAME', $fileName), 500);
return false;
}
// Trigger the onExtensionAfterSave event.
//$dispatcher->trigger('onExtensionAfterSave', array('com_templates.source', &$table, false));
//return true;
return parent::save($data);
}
public function delete(&$pks)
{
//$dispatcher = JEventDispatcher::getInstance();
$pks = (array) $pks;
$table = $this->getTable();
// Include the content plugins for the on delete events.
PluginHelper::importPlugin('content');
// Iterate the items to delete each one.
foreach ($pks as $i => $pk)
{
if ($table->load($pk))
{
if ($this->canDelete($table))
{
$context = $this->option . '.' . $this->name;
// Trigger the onContentBeforeDelete event.
$result = Factory::getApplication()->triggerEvent($this->event_before_delete, array($context, $table));
if (in_array(false, $result, true))
{
throw new Exception($table->getError(), 500);
return false;
}
//PHOCAEDIT
$filePath = PhocaDownloadFile::getCSSFile($pk, true);
//END PHOCAEDIT
if (!$table->delete($pk))
{
throw new Exception($table->getError(), 500);
return false;
}
//PHOCAEDIT
if (file_exists($filePath)) {
File::delete($filePath);
}
//END PHOCAEDIT
// Trigger the onContentAfterDelete event.
Factory::getApplication()->triggerEvent($this->event_after_delete, array($context, $table));
}
else
{
// Prune items that you can't change.
unset($pks[$i]);
$error = $this->getError();
if ($error)
{
Log::add($error, Log::WARNING, '');
return false;
}
else
{
Log::add(Text::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), Log::WARNING, '');
return false;
}
}
}
else
{
throw new Exception($table->getError(), 500);
return false;
}
}
// Clear the component's cache
$this->cleanCache();
return true;
}
}
?>

View File

@ -0,0 +1,267 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined( '_JEXEC' ) or die();
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Language\Text;
jimport( 'joomla.application.component.modellist' );
jimport( 'joomla.filesystem.folder' );
jimport( 'joomla.filesystem.file' );
class PhocaDownloadCpModelPhocaDownloadStyles extends ListModel
{
protected $option = 'com_phocadownload';
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'alias', 'a.alias',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'type', 'a.type',
'published', 'a.published',
'ordering', 'a.ordering',
'language', 'a.language'
);
}
parent::__construct($config);
}
protected function populateState($ordering = 'a.ordering', $direction = 'ASC')
{
// Initialise variables.
$app = Factory::getApplication('administrator');
// Load the filter state.
$search = $app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
/*
$accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int');
$this->setState('filter.access', $accessId);
*/
$state = $app->getUserStateFromRequest($this->context.'.filter.published', 'filter_published', '', 'string');
$this->setState('filter.published', $state);
$categoryId = $app->getUserStateFromRequest($this->context.'.filter.category_id', 'filter_category_id', null);
$this->setState('filter.category_id', $categoryId);
$language = $app->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
// Load the parameters.
$params = ComponentHelper::getParams('com_phocadownload');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.search');
$id .= ':'.$this->getState('filter.published');
$id .= ':'.$this->getState('filter.category_id');
return parent::getStoreId($id);
}
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from('`#__phocadownload_styles` AS a');
// Join over the language
$query->select('l.title AS language_title');
$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Filter by published state.
$published = $this->getState('filter.published');
if (is_numeric($published)) {
$query->where('a.published = '.(int) $published);
}
else if ($published === '') {
$query->where('(a.published IN (0, 1))');
}
// Filter by category.
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId)) {
$query->where('a.type = ' . (int) $categoryId);
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
}
else
{
$search = $db->Quote('%'.$db->escape($search, true).'%');
$query->where('( a.title LIKE '.$search.' OR a.filename LIKE '.$search.')');
}
}
$query->group('a.id');
// Add the list ordering clause.
//$orderCol = $this->state->get('list.ordering');
//$orderDirn = $this->state->get('list.direction');
/*if ($orderCol == 'a.ordering' || $orderCol == 'category_title') {
$orderCol = 'category_title '.$orderDirn.', a.ordering';
}*/
// Add the list ordering clause.
//$orderCol = $this->state->get('list.ordering');
//$orderDirn = $this->state->get('list.direction');
$orderCol = $this->state->get('list.ordering', 'ordering');
$orderDirn = $this->state->get('list.direction', 'asc');
if ($orderCol == 'a.ordering' || $orderCol == 'category_title') {
$orderCol = 'a.type '.$orderDirn.', a.ordering';
}
$query->order($db->escape($orderCol.' '.$orderDirn));
return $query;
}
protected function getItemsCheck() {
$db = Factory::getDBO();
$query = 'SELECT a.id, a.filename, a.type'
.' FROM #__phocadownload_styles AS a';
$db->setQuery($query);
$items = $db->loadObjectList();
return $items;
}
public function checkItems() {
$db = Factory::getDBO();
$files = $this->getFiles();
$items = $this->getItemsCheck();
if (!empty($files)) {
foreach ($files as $fk => $fv) {
if ($fv->exists) {
$exists = 0;
foreach ($items as $ik => $iv) {
if ($fv->filename == $iv->filename && $fv->type == $iv->type){
// we cannot break because there are two types
$exists = 1;
}
}
if ($exists == 0) {
$query = 'SELECT a.ordering'
.' FROM #__phocadownload_styles AS a'
.' WHERE a.type = '.(int) $fv->type;
$db->setQuery($query, 0, 1);
$ordO = $db->loadObject();
if (!isset($ordO->ordering)) {
$ordering = 1;
} else {
$ordering = (int)$ordO->ordering + 1;
}
$title = ucfirst(str_replace('.css', '', htmlspecialchars($fv->filename)));
$published = 1;
$query = 'INSERT into #__phocadownload_styles'
.' (id, title, filename, type, published, ordering, language)'
.' VALUES (null, '. $db->quote($title)
.' , '.$db->quote(htmlspecialchars($fv->filename))
.' , '.(int)$fv->type
.' , '.(int)$published
.' , '.(int)$ordering
.' , '.$db->quote('*')
.')';
$db->setQuery($query);
if (!$db->execute()) {
throw new Exception('Database Error - Inserting CSS Style', 500);
return false;
}
}
}
}
}
return true;
}
public function getFiles()
{
$result = array();
jimport('joomla.filesystem.folder');
$paths = PhocaDownloadPath::getPathMedia();
$path = Path::clean($paths->media_css_abs . '/main/');
if (is_dir($path)) {
$files = Folder::files($path, '\.css$', false, false);
foreach ($files as $file) {
$fileO = new stdClass;
$fileO->filename = $file;
$fileO->exists = file_exists($path.$file);
$fileO->type = 1;
$result[] = $fileO;
}
} else {
throw new Exception(Text::_('COM_PHOCADOWNLOAD_ERROR_CSS_FOLDER_NOT_FOUND') . ' (1)', 500);
return false;
}
$path = Path::clean($paths->media_css_abs . '/custom/');
if (is_dir($path)) {
$files = Folder::files($path, '\.css$', false, false);
foreach ($files as $file) {
$fileO = new stdClass;
$fileO->filename = $file;
$fileO->exists = file_exists($path.$file);
$fileO->type = 2;
$result[] = $fileO;
}
} else {
throw new Exception(Text::_('COM_PHOCADOWNLOAD_ERROR_CSS_FOLDER_NOT_FOUND') . ' (2)', 500);
return false;
}
return $result;
}
}
?>

View File

@ -0,0 +1,99 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined( '_JEXEC' ) or die();
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\ApplicationHelper;
jimport('joomla.application.component.modeladmin');
class PhocaDownloadCpModelPhocaDownloadTag extends AdminModel
{
protected $option = 'com_phocadownload';
protected $text_prefix = 'com_phocadownload';
public $typeAlias = 'com_phocadownload.phocadownloadtag';
protected function canDelete($record)
{
//$user = JFactory::getUser();
return parent::canDelete($record);
}
protected function canEditState($record)
{
//$user = JFactory::getUser();
return parent::canEditState($record);
}
public function getTable($type = 'PhocaDownloadTag', $prefix = 'Table', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
public function getForm($data = array(), $loadData = true) {
$app = Factory::getApplication();
$form = $this->loadForm('com_phocadownload.phocadownloadtag', 'phocadownloadtag', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = Factory::getApplication()->getUserState('com_phocadownload.edit.phocadownloadtag.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
protected function prepareTable($table)
{
jimport('joomla.filter.output');
$date = Factory::getDate();
$user = Factory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = ApplicationHelper::stringURLSafe($table->alias);
$table->link_cat = PhocaDownloadUtils::getIntFromString($table->link_cat);
if (empty($table->alias)) {
$table->alias = ApplicationHelper::stringURLSafe($table->title);
}
if (empty($table->id)) {
// Set the values
//$table->created = $date->toSql();
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = Factory::getDbo();
$db->setQuery('SELECT MAX(ordering) FROM #__phocadownload_tags');
$max = $db->loadResult();
$table->ordering = $max+1;
}
}
else {
// Set the values
//$table->modified = $date->toSql();
//$table->modified_by = $user->get('id');
}
}
}
?>

View File

@ -0,0 +1,154 @@
<?php
/*
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
*/
defined( '_JEXEC' ) or die();
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
jimport('joomla.application.component.modellist');
class PhocaDownloadCpModelPhocaDownloadTags extends ListModel
{
protected $option = 'com_phocadownload';
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'alias', 'a.alias',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'ordering', 'a.ordering',
'published','a.published',
);
}
parent::__construct($config);
}
protected function populateState($ordering = 'a.title', $direction = 'ASC')
{
// Initialise variables.
$app = Factory::getApplication('administrator');
// Load the filter state.
$search = $app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
/* $accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int');
$this->setState('filter.access', $accessId);*/
$state = $app->getUserStateFromRequest($this->context.'.filter.published', 'filter_published', '', 'string');
$this->setState('filter.published', $state);
//$language = $app->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', '');
//$this->setState('filter.language', $language);
// Load the parameters.
$params = ComponentHelper::getParams('com_phocadownload');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.search');
//$id .= ':'.$this->getState('filter.access');
$id .= ':'.$this->getState('filter.published');
$id .= ':'.$this->getState('filter.tag_id');
return parent::getStoreId($id);
}
protected function getListQuery()
{
/*
$query = ' SELECT a.*, u.name AS editor '
. ' FROM #__phocadownload_licenses AS a '
. ' LEFT JOIN #__users AS u ON u.id = a.checked_out '
*/
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from('`#__phocadownload_tags` AS a');
// Join over the language
//$query->select('l.title AS language_title');
//$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Filter by access level.
/* if ($access = $this->getState('filter.access')) {
$query->where('a.access = '.(int) $access);
}*/
// Filter by published state.
$published = $this->getState('filter.published');
if (is_numeric($published)) {
$query->where('a.published = '.(int) $published);
}
else if ($published === '') {
$query->where('(a.published IN (0, 1))');
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
}
else
{
$search = $db->Quote('%'.$db->escape($search, true).'%');
$query->where('( a.title LIKE '.$search.' OR a.alias LIKE '.$search.')');
}
}
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
$query->order($db->escape($orderCol.' '.$orderDirn));
//echo nl2br(str_replace('#__', 'jos_', $query->__toString()));
return $query;
}
}
?>

View File

@ -0,0 +1,31 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('_JEXEC') or die();
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
jimport('joomla.application.component.model');
class PhocaDownloadCpModelPhocaDownloadUpload extends BaseDatabaseModel
{
function __construct() {
parent::__construct();
}
function approveall() {
//$user = JFactory::getUser();
$query = 'UPDATE #__phocadownload'
. ' SET approved = 1';
//. ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )';
$this->_db->setQuery( $query );
if (!$this->_db->execute()) {
throw new Exception($this->_db->getError());
return false;
}
return true;
}
}
?>

View File

@ -0,0 +1,224 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('_JEXEC') or die();
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
jimport('joomla.application.component.modellist');
jimport( 'joomla.filesystem.folder' );
jimport( 'joomla.filesystem.file' );
class PhocaDownloadCpModelPhocaDownloadUploads extends ListModel
{
protected $option = 'com_phocadownload';
public $context = 'com_phocadownload.phocadownloaduploads';
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'a.id',
'username', 'ua.username',
'usernameno', 'ua.usernameno',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'category_id', 'category_id',
'state', 'a.state',
'access', 'a.access', 'access_level',
'ordering', 'a.ordering',
'language', 'a.language',
'hits', 'a.hits',
'published','a.published',
'authorized','a.approved'
);
}
parent::__construct($config);
}
protected function populateState($ordering = 'username', $direction = 'ASC')
{
// Initialise variables.
$app = Factory::getApplication('administrator');
// Load the filter state.
$search = $app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
$this->setState('filter.search', $search);
/*
$accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int');
$this->setState('filter.access', $accessId);
*/
$state = $app->getUserStateFromRequest($this->context.'.filter.published', 'filter_published', '', 'string');
$this->setState('filter.published', $state);
/*
$categoryId = $app->getUserStateFromRequest($this->context.'.filter.category_id', 'filter_category_id', null);
$this->setState('filter.category_id', $categoryId);
$language = $app->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
*/
// Load the parameters.
$params = ComponentHelper::getParams('com_phocadownload');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.search');
//$id .= ':'.$this->getState('filter.access');
$id .= ':'.$this->getState('filter.published');
return parent::getStoreId($id);
}
protected function getListQuery()
{
/*
$query = ' SELECT a.*, fa.countfaid, fn.countfnid, 0 AS checked_out'
. ' FROM #__users AS a'
. ' LEFT JOIN #__phocadownload AS f ON f.owner_id = a.id '
. ' LEFT JOIN #__phocadownload_categories AS cc ON cc.id = f.catid '
. ' LEFT JOIN #__phocadownload_sections AS s ON s.id = f.sectionid '
. ' LEFT JOIN #__groups AS g ON g.id = f.access '
. ' LEFT JOIN #__users AS aa ON aa.id = f.checked_out '
. ' LEFT JOIN (SELECT fa.owner_id, fa.id, count(*) AS countfaid'
. ' FROM #__phocadownload AS fa'
. ' WHERE fa.approved = 1'
. ' GROUP BY fa.owner_id) AS fa '
. ' ON a.id = fa.owner_id'
. ' LEFT JOIN (SELECT fn.owner_id, fn.id, count(*) AS countfnid'
. ' FROM #__phocadownload AS fn'
. ' WHERE fn.approved = 0'
. ' GROUP BY fn.owner_id) AS fn '
. ' ON a.id = fn.owner_id'
. $where
. ' GROUP by a.id'
. $orderby;
*/
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id'
)
);
$query->from('#__users AS a');
// Join over the language
//$query->select('l.title AS language_title');
//$query->join('LEFT', '#__languages AS l ON l.lang_code = a.language');
$query->select('GROUP_CONCAT(DISTINCT f.id) AS file_id');
$query->join('LEFT', '#__phocadownload AS f ON f.owner_id = a.id');
$query->select('cc.id as category_id');
$query->join('LEFT', '#__phocadownload_categories AS cc ON cc.id = f.catid');
// Join over the users for the checked out user.
//$query->select('ua.id AS userid, ua.username AS username, ua.name AS usernameno');
//$query->join('LEFT', '#__users AS ua ON ua.id=a.userid');
$query->select('ua.id AS userid, ua.username AS username, ua.name AS usernameno');
$query->join('LEFT', '#__users AS ua ON ua.id=f.owner_id');
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id=f.checked_out');
$query->select('fa.countfaid');
$query->join('LEFT', '(SELECT fa.owner_id, count(*) AS countfaid'
. ' FROM #__phocadownload AS fa'
. ' WHERE fa.approved = 1'
. ' GROUP BY fa.owner_id) AS fa '
. ' ON a.id = fa.owner_id ');
$query->select('fn.countfnid');
$query->join('LEFT', '(SELECT fn.owner_id, count(*) AS countfnid'
. ' FROM #__phocadownload AS fn'
. ' WHERE fn.approved = 0'
. ' GROUP BY fn.owner_id) AS fn '
. ' ON a.id = fn.owner_id');
/* // Join over the asset groups.
$query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
*/
// Filter by access level.
/* if ($access = $this->getState('filter.access')) {
$query->where('a.access = '.(int) $access);
}*/
// Filter by published state.
/*$published = $this->getState('filter.published');
if (is_numeric($published)) {
$query->where('a.published = '.(int) $published);
}
else if ($published === '') {
$query->where('(a.published IN (0, 1))');
}*/
$query->where('a.id > 0');
$query->where('(fa.countfaid > 0 OR fn.countfnid > 0)');
// Filter by category.
/*$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId)) {
$query->where('a.catid = ' . (int) $categoryId);
}*/
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0) {
$query->where('a.id = '.(int) substr($search, 3));
}
else
{
$search = $db->Quote('%'.$db->escape($search, true).'%');
$query->where('( ua.username LIKE '.$search.' OR ua.name LIKE '.$search.')');
}
}
$query->group('a.username, ua.id, a.id, a.name, cc.id, ua.username, ua.name, uc.name, fa.countfaid, fn.countfnid');
// Add the list ordering clause.
//$orderCol = $this->state->get('list.ordering');
//$orderDirn = $this->state->get('list.direction');
$orderCol = $this->state->get('list.ordering', 'username');
$orderDirn = $this->state->get('list.direction', 'asc');
if ($orderCol == 'a.id' || $orderCol == 'username') {
$orderCol = 'a.username '.$orderDirn.', a.id';
}
$query->order($db->escape($orderCol.' '.$orderDirn));
// echo nl2br(str_replace('#__', 'jos_', $query->__toString()));
return $query;
}
}
?>