| Current Path : /home/w/u/e/wuectly/www/03cbe/ |
| Current File : /home/w/u/e/wuectly/www/03cbe/helper.tar |
mediahelper.php 0000604 00000006135 15245530276 0007546 0 ustar 00 <?php
final class WfMediaHelper {
/**
* An array of supported embed types and their mime types
*/
private static $embedMimes = array(
"doc"=> "application/msword",
"xls"=> "application/vnd.ms-excel",
"ppt"=> "application/vnd.ms-powerpoint",
"dot"=> "application/msword",
"pps"=> "application/vnd.ms-powerpoint",
"docx"=> "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"dotx"=> "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
"pptx"=> "application/vnd.openxmlformats-officedocument.presentationml.presentation",
"xlsx"=> "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"xlsm"=> "application/vnd.ms-excel.sheet.macroEnabled.12",
"ppsx"=> "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
"sldx"=> "application/vnd.openxmlformats-officedocument.presentationml.slide",
"potx"=> "application/vnd.openxmlformats-officedocument.presentationml.template",
"xltx"=> "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
"odt"=> "application/vnd.oasis.opendocument.text",
"odg"=> "application/vnd.oasis.opendocument.graphics",
"odp"=> "application/vnd.oasis.opendocument.presentation",
"ods"=> "application/vnd.oasis.opendocument.spreadsheet",
"odf"=> "application/vnd.oasis.opendocument.formula",
"txt"=> "text/plain",
"rtf"=> "application/rtf",
"md"=> "text/markdown",
"pdf"=> "application/pdf"
);
/**
* An array of supported media layout types and their file extensions
*/
private static $allowable = array(
'image' => 'jpg,jpeg,png,gif',
'audio' => 'mp3,m4a,mp4a,ogg',
'video' => 'mp4,mp4v,mpeg,mov,webm',
'object' => 'doc,docx,odg,odp,ods,odt,pdf,ppt,pptx,txt,xcf,xls,xlsx,csv',
'iframe' => '',
);
/**
* Get the embed type from the file extension
*
* @param [string] $extension File extension
* @return Mime type or false
*/
public static function getMimeType($extension) {
if (array_key_exists($extension, self::$embedMimes)) {
return self::$embedMimes[$extension];
}
return false;
}
/**
* Get the media layout from the file extension
*
* @param [type] $extension File extension
* @return Layout type
*/
public static function getLayoutFromExtension($extension) {
$layout = 'link';
array_walk(self::$allowable, function ($values, $key) use ($extension, &$layout) {
if (in_array($extension, explode(',', $values))) {
$layout = $key;
}
});
return $layout;
}
/**
* Determine whether the value is an image
*
* @param [string] $value
* @return boolean
*/
public static function isImage($value) {
$extension = pathinfo($value, PATHINFO_EXTENSION);
return in_array($extension, explode(',', self::$allowable['image']));
}
} config.php 0000604 00000005637 15245607037 0006542 0 ustar 00 <?php
/**
* @package Joomla.Administrator
* @subpackage com_config
*
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Components helper for com_config
*
* @since 3.0
*/
class ConfigHelperConfig extends JHelperContent
{
/**
* Get an array of all enabled components.
*
* @return array
*
* @since 3.0
*/
public static function getAllComponents()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('element')
->from('#__extensions')
->where('type = ' . $db->quote('component'))
->where('enabled = 1');
$db->setQuery($query);
$result = $db->loadColumn();
return $result;
}
/**
* Returns true if the component has configuration options.
*
* @param string $component Component name
*
* @return boolean
*
* @since 3.0
*/
public static function hasComponentConfig($component)
{
return is_file(JPATH_ADMINISTRATOR . '/components/' . $component . '/config.xml');
}
/**
* Returns an array of all components with configuration options.
* Optionally return only those components for which the current user has 'core.manage' rights.
*
* @param boolean $authCheck True to restrict to components where current user has 'core.manage' rights.
*
* @return array
*
* @since 3.0
*/
public static function getComponentsWithConfig($authCheck = true)
{
$result = array();
$components = self::getAllComponents();
$user = JFactory::getUser();
// Remove com_config from the array as that may have weird side effects
$components = array_diff($components, array('com_config'));
foreach ($components as $component)
{
if (self::hasComponentConfig($component) && (!$authCheck || $user->authorise('core.manage', $component)))
{
self::loadLanguageForComponent($component);
$result[$component] = JApplicationHelper::stringURLSafe(JText::_($component)) . '_' . $component;
}
}
asort($result);
return array_keys($result);
}
/**
* Load the sys language for the given component.
*
* @param array $components Array of component names.
*
* @return void
*
* @since 3.0
*/
public static function loadLanguageForComponents($components)
{
foreach ($components as $component)
{
self::loadLanguageForComponent($component);
}
}
/**
* Load the sys language for the given component.
*
* @param string $component component name.
*
* @return void
*
* @since 3.5
*/
public static function loadLanguageForComponent($component)
{
if (empty($component))
{
return;
}
$lang = JFactory::getLanguage();
// Load the core file then
// Load extension-local file.
$lang->load($component . '.sys', JPATH_BASE, null, false, true)
|| $lang->load($component . '.sys', JPATH_ADMINISTRATOR . '/components/' . $component, null, false, true);
}
}