AAAAhome/academiac/www/administrator/components/com_installer/models/extension.php 0000644 00000011516 15137210454 0024125 0 ustar 00 getState('list.ordering');
$search = $this->getState('filter.search');
// Replace slashes so preg_match will work
$search = str_replace('/', ' ', $search);
$db = $this->getDbo();
if ($ordering == 'name' || (!empty($search) && stripos($search, 'id:') !== 0)) {
$db->setQuery($query);
$result = $db->loadObjectList();
$lang = JFactory::getLanguage();
$this->translate($result);
if (!empty($search)) {
foreach($result as $i=>$item) {
if (!preg_match("/$search/i", $item->name)) {
unset($result[$i]);
}
}
}
JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == 'desc' ? -1 : 1, true, $lang->getLocale());
$total = count($result);
$this->cache[$this->getStoreId('getTotal')] = $total;
if ($total < $limitstart) {
$limitstart = 0;
$this->setState('list.start', 0);
}
return array_slice($result, $limitstart, $limit ? $limit : null);
} else {
$query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
$result = parent::_getList($query, $limitstart, $limit);
$this->translate($result);
return $result;
}
}
/**
* Translate a list of objects
*
* @param array The array of objects
* @return array The array of translated objects
*/
private function translate(&$items)
{
$lang = JFactory::getLanguage();
foreach($items as &$item) {
if (strlen($item->manifest_cache)) {
$data = json_decode($item->manifest_cache);
if ($data) {
foreach($data as $key => $value) {
if ($key == 'type') {
// ignore the type field
continue;
}
$item->$key = $value;
}
}
}
$item->author_info = @$item->authorEmail .'
'. @$item->authorUrl;
$item->client = $item->client_id ? JText::_('JADMINISTRATOR') : JText::_('JSITE');
$path = $item->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE;
switch ($item->type) {
case 'component':
$extension = $item->element;
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, true)
|| $lang->load("$extension.sys", $source, null, false, true);
break;
case 'file':
$extension = 'files_' . $item->element;
$lang->load("$extension.sys", JPATH_SITE, null, false, true);
break;
case 'library':
$extension = 'lib_' . $item->element;
$lang->load("$extension.sys", JPATH_SITE, null, false, true);
break;
case 'module':
$extension = $item->element;
$source = $path . '/modules/' . $extension;
$lang->load("$extension.sys", $path, null, false, true)
|| $lang->load("$extension.sys", $source, null, false, true);
break;
case 'package':
$extension = $item->element;
$lang->load("$extension.sys", JPATH_SITE, null, false, true);
break;
case 'plugin':
$extension = 'plg_' . $item->folder . '_' . $item->element;
$source = JPATH_PLUGINS . '/' . $item->folder . '/' . $item->element;
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, true)
|| $lang->load("$extension.sys", $source, null, false, true);
break;
case 'template':
$extension = 'tpl_' . $item->element;
$source = $path . '/templates/' . $item->element;
$lang->load("$extension.sys", $path, null, false, true)
|| $lang->load("$extension.sys", $source, null, false, true);
break;
}
if (!in_array($item->type, array('language', 'template', 'library'))) {
$item->name = JText::_($item->name);
}
settype($item->description, 'string');
if (!in_array($item->type, array('language'))) {
$item->description = JText::_($item->description);
}
}
}
}
home/academiac/www/libraries/joomla/installer/extension.php 0000644 00000005572 15137270217 0020204 0 ustar 00 type = (string) $element->attributes()->type;
$this->id = (string) $element->attributes()->id;
switch ($this->type)
{
case 'component':
// By default a component doesn't have anything
break;
case 'module':
case 'template':
case 'language':
$this->client = (string) $element->attributes()->client;
$tmp_client_id = JApplicationHelper::getClientInfo($this->client, 1);
if ($tmp_client_id == null)
{
JError::raiseWarning(100, JText::_('JLIB_INSTALLER_ERROR_EXTENSION_INVALID_CLIENT_IDENTIFIER'));
}
else
{
$this->client_id = $tmp_client_id->id;
}
break;
case 'plugin':
$this->group = (string) $element->attributes()->group;
break;
default:
// Catch all
// Get and set client and group if we don't recognise the extension
if ($client = (string) $element->attributes()->client)
{
$this->client_id = JApplicationHelper::getClientInfo($this->client, 1);
$this->client_id = $this->client_id->id;
}
if ($group = (string) $element->attributes()->group)
{
$this->group = (string) $element->attributes()->group;
}
break;
}
$this->filename = (string) $element;
}
}
}
home/academiac/www/libraries/joomla/database/table/extension.php 0000644 00000011551 15137272033 0021032 0 ustar 00 name) == '' || trim($this->element) == '')
{
$this->setError(JText::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_EXTENSION'));
return false;
}
return true;
}
/**
* Overloaded bind function
*
* @param array $array Named array
* @param mixed $ignore An optional array or space separated list of properties
* to ignore while binding.
*
* @return mixed Null if operation was satisfactory, otherwise returns an error
*
* @see JTable::bind
* @since 11.1
*/
public function bind($array, $ignore = '')
{
if (isset($array['params']) && is_array($array['params']))
{
$registry = new JRegistry;
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
if (isset($array['control']) && is_array($array['control']))
{
$registry = new JRegistry;
$registry->loadArray($array['control']);
$array['control'] = (string) $registry;
}
return parent::bind($array, $ignore);
}
/**
* Method to create and execute a SELECT WHERE query.
*
* @param array $options Array of options
*
* @return JDatabase The database query result
*
* @since 11.1
*/
public function find($options = array())
{
// Get the JDatabaseQuery object
$query = $this->_db->getQuery(true);
foreach ($options as $col => $val)
{
$query->where($col . ' = ' . $this->_db->quote($val));
}
$query->select($this->_db->quoteName('extension_id'));
$query->from($this->_db->quoteName('#__extensions'));
$this->_db->setQuery($query);
return $this->_db->loadResult();
}
/**
* Method to set the publishing state for a row or list of rows in the database
* table. The method respects checked out rows by other users and will attempt
* to checkin rows that it can after adjustments are made.
*
* @param mixed $pks An optional array of primary key values to update. If not
* set the instance property value is used.
* @param integer $state The publishing state. eg. [0 = unpublished, 1 = published]
* @param integer $userId The user id of the user performing the operation.
*
* @return boolean True on success.
*
* @since 11.1
*/
public function publish($pks = null, $state = 1, $userId = 0)
{
// Initialise variables.
$k = $this->_tbl_key;
// Sanitize input.
JArrayHelper::toInteger($pks);
$userId = (int) $userId;
$state = (int) $state;
// If there are no primary keys set check to see if the instance key is set.
if (empty($pks))
{
if ($this->$k)
{
$pks = array($this->$k);
}
// Nothing to set publishing state on, return false.
else
{
$this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
return false;
}
}
// Build the WHERE clause for the primary keys.
$where = $k . '=' . implode(' OR ' . $k . '=', $pks);
// Determine if there is checkin support for the table.
if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time'))
{
$checkin = '';
}
else
{
$checkin = ' AND (checked_out = 0 OR checked_out = ' . (int) $userId . ')';
}
// Get the JDatabaseQuery object
$query = $this->_db->getQuery(true);
// Update the publishing state for rows with the given primary keys.
$query->update($this->_db->quoteName($this->_tbl));
$query->set($this->_db->quoteName('enabled') . ' = ' . (int) $state);
$query->where('(' . $where . ')' . $checkin);
$this->_db->setQuery($query);
$this->_db->execute();
// Check for a database error.
if ($this->_db->getErrorNum())
{
$this->setError($this->_db->getErrorMsg());
return false;
}
// If checkin is supported and all rows were adjusted, check them in.
if ($checkin && (count($pks) == $this->_db->getAffectedRows()))
{
// Checkin the rows.
foreach ($pks as $pk)
{
$this->checkin($pk);
}
}
// If the JTable instance value is in the list of primary keys that were set, set the instance.
if (in_array($this->$k, $pks))
{
$this->enabled = $state;
}
$this->setError('');
return true;
}
}
home/academiac/www/libraries/joomla/updater/adapters/extension.php 0000644 00000015606 15137272407 0021460 0 ustar 00 _stack, $name);
$tag = $this->_getStackLocation();
// Reset the data
if (isset($this->$tag))
{
$this->$tag->_data = "";
}
switch ($name)
{
case 'UPDATE':
$this->current_update = JTable::getInstance('update');
$this->current_update->update_site_id = $this->_update_site_id;
$this->current_update->detailsurl = $this->_url;
$this->current_update->folder = "";
$this->current_update->client_id = 1;
break;
// Don't do anything
case 'UPDATES':
// Store compatibility info per updates block (usually one per file)
$this->compatibility = array();
break;
default:
if (in_array($name, $this->_updatecols))
{
$name = strtolower($name);
$this->current_update->$name = '';
}
if ($name == 'TARGETPLATFORM')
{
$this->current_update->targetplatform = $attrs;
if (isset($attrs['NAME']) && ($attrs['NAME'] == 'joomla') && !empty($attrs['VERSION']))
{
$this->current_update->compatibility = $attrs['VERSION'];
}
}
if ($name == 'PHP_MINIMUM')
{
$this->current_update->php_minimum = '';
}
break;
}
}
/**
* Character Parser Function
*
* @param object $parser Parser object.
* @param object $name The name of the element.
*
* @return void
*
* @since 11.1
*/
protected function _endElement($parser, $name)
{
array_pop($this->_stack);
//echo 'Closing: '. $name .'
';
switch ($name)
{
case 'UPDATE':
$ver = new JVersion;
$product = strtolower(JFilterInput::getInstance()->clean($ver->PRODUCT, 'cmd')); // lower case and remove the exclamation mark
// Keep compatibility information in class property
if (isset($this->current_update->compatibility))
{
$this->compatibility[$this->current_update->version][] = $this->current_update->compatibility;
unset($this->current_update->compatibility);
}
// Check that the product matches and that the version matches (optionally a regexp)
if ($product == $this->current_update->targetplatform['NAME']
&& preg_match('/' . $this->current_update->targetplatform['VERSION'] . '/', $ver->RELEASE))
{
// Check if PHP version supported via tag, assume true if tag isn't present
if (!isset($this->current_update->php_minimum) || version_compare(PHP_VERSION, $this->current_update->php_minimum, '>='))
{
$phpMatch = true;
}
else
{
// Notify the user of the potential update
$msg = JText::sprintf(
'JLIB_INSTALLER_AVAILABLE_UPDATE_PHP_VERSION',
$this->current_update->name,
$this->current_update->version,
$this->current_update->php_minimum,
PHP_VERSION
);
JFactory::getApplication()->enqueueMessage($msg, 'warning');
$phpMatch = false;
}
// Target platform and php_minimum aren't valid fields in the update table so unset them to prevent J! from trying to store them
unset($this->current_update->targetplatform);
unset($this->current_update->php_minimum);
if ($phpMatch)
{
if (isset($this->latest))
{
if (version_compare($this->current_update->version, $this->latest->version, '>') == 1)
{
$this->latest = $this->current_update;
}
}
else
{
$this->latest = $this->current_update;
}
}
}
break;
case 'UPDATES':
// :D
break;
}
}
/**
* Character Parser Function
*
* @param object $parser Parser object.
* @param object $data The data.
*
* @return void
*
* @note This is public because its called externally.
* @since 11.1
*/
protected function _characterData($parser, $data)
{
$tag = $this->_getLastTag();
//if(!isset($this->$tag->_data)) $this->$tag->_data = '';
//$this->$tag->_data .= $data;
if (in_array($tag, $this->_updatecols))
{
$tag = strtolower($tag);
$this->current_update->$tag .= $data;
}
if ($tag == 'PHP_MINIMUM')
{
$this->current_update->php_minimum = $data;
}
}
/**
* Finds an update.
*
* @param array $options Update options.
*
* @return array Array containing the array of update sites and array of updates
*
* @since 11.1
*/
public function findUpdate($options)
{
$url = trim($options['location']);
$this->_url = &$url;
$this->_update_site_id = $options['update_site_id'];
if (substr($url, -4) != '.xml')
{
if (substr($url, -1) != '/')
{
$url .= '/';
}
$url .= 'extension.xml';
}
$dbo = $this->parent->getDBO();
$http = JHttpFactory::getHttp();
try
{
$response = $http->get($url);
}
catch (Exception $exc)
{
$response = null;
}
if (is_null($response) || ($response->code != 200))
{
$query = $dbo->getQuery(true);
$query->update('#__update_sites');
$query->set('enabled = 0');
$query->where('update_site_id = ' . $this->_update_site_id);
$dbo->setQuery($query);
$dbo->execute();
JLog::add("Error opening url: " . $url, JLog::WARNING, 'updater');
$app = JFactory::getApplication();
$app->enqueueMessage(JText::sprintf('JLIB_UPDATER_ERROR_EXTENSION_OPEN_URL', $url), 'warning');
return false;
}
$this->xml_parser = xml_parser_create('');
xml_set_object($this->xml_parser, $this);
xml_set_element_handler($this->xml_parser, '_startElement', '_endElement');
xml_set_character_data_handler($this->xml_parser, '_characterData');
if (!xml_parse($this->xml_parser, $response->body))
{
JLog::add("Error parsing url: " . $url, JLog::WARNING, 'updater');
$app = JFactory::getApplication();
$app->enqueueMessage(JText::sprintf('JLIB_UPDATER_ERROR_EXTENSION_PARSE_URL', $url), 'warning');
return false;
}
xml_parser_free($this->xml_parser);
if (isset($this->latest))
{
if (isset($this->latest->client) && strlen($this->latest->client))
{
$this->latest->client_id = JApplicationHelper::getClientInfo($this->latest->client, 1)->id;
unset($this->latest->client);
}
$updates = array($this->latest);
}
else
{
$updates = array();
}
return array('update_sites' => array(), 'updates' => $updates, 'compatibility' => $this->compatibility);
}
}