Skip to content

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
rohit053 committed Nov 2, 2015
1 parent c2397b3 commit abb42e6
Show file tree
Hide file tree
Showing 9,331 changed files with 924,618 additions and 29 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
29 changes: 0 additions & 29 deletions .gitignore

This file was deleted.

51 changes: 51 additions & 0 deletions Adapter/Adapter_AddressFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

class Adapter_AddressFactory
{
/**
* Initilize an address corresponding to the specified id address or if empty to the
* default shop configuration
* @param null $id_address
* @param bool $with_geoloc
* @return Address
*/
public function findOrCreate($id_address = null, $with_geoloc = false)
{
$func_args = func_get_args();
return call_user_func_array(array('Address', 'initialize'), $func_args);
}

/**
* Check if an address exists depending on given $id_address
* @param $id_address
* @return bool
*/
public function addressExists($id_address)
{
return Address::addressExists($id_address);
}
}
38 changes: 38 additions & 0 deletions Adapter/Adapter_CacheManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

class Adapter_CacheManager
{
/**
* Cleans the cache for specific cache key.
*
* @param $key
*/
public function clean($key)
{
Cache::clean($key);
}
}
43 changes: 43 additions & 0 deletions Adapter/Adapter_Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

class Adapter_Configuration implements Core_Business_ConfigurationInterface
{
/**
* Returns constant defined by given $key if exists or check directly into PrestaShop
* Configuration
* @param $key
* @return mixed
*/
public function get($key)
{
if (defined($key)) {
return constant($key);
} else {
return Configuration::get($key);
}
}
}
52 changes: 52 additions & 0 deletions Adapter/Adapter_Database.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

class Adapter_Database implements Core_Foundation_Database_DatabaseInterface
{
/**
* Perform a SELECT sql statement
* @param $sqlString
* @return array|false
* @throws PrestaShopDatabaseException
*/
public function select($sqlString)
{
return Db::getInstance()->executeS($sqlString);
}

/**
* Escape $unsafe to be used into a SQL statement
* @param $unsafeData
* @return string
*/
public function escape($unsafeData)
{
// Prepare required params
$html_ok = true;
$bq_sql = true;
return Db::getInstance()->escape($unsafeData, $html_ok, $bq_sql);
}
}
104 changes: 104 additions & 0 deletions Adapter/Adapter_EntityMapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

class Adapter_EntityMapper
{
/**
* Load ObjectModel
* @param $id
* @param $id_lang
* @param $entity ObjectModel
* @param $entity_defs
* @param $id_shop
* @param $should_cache_objects
* @throws PrestaShopDatabaseException
*/
public function load($id, $id_lang, $entity, $entity_defs, $id_shop, $should_cache_objects)
{
// Load object from database if object id is present
$cache_id = 'objectmodel_' . $entity_defs['classname'] . '_' . (int)$id . '_' . (int)$id_shop . '_' . (int)$id_lang;
if (!$should_cache_objects || !Cache::isStored($cache_id)) {
$sql = new DbQuery();
$sql->from($entity_defs['table'], 'a');
$sql->where('a.`' . bqSQL($entity_defs['primary']) . '` = ' . (int)$id);

// Get lang informations
if ($id_lang && isset($entity_defs['multilang']) && $entity_defs['multilang']) {
$sql->leftJoin($entity_defs['table'] . '_lang', 'b', 'a.`' . bqSQL($entity_defs['primary']) . '` = b.`' . bqSQL($entity_defs['primary']) . '` AND b.`id_lang` = ' . (int)$id_lang);
if ($id_shop && !empty($entity_defs['multilang_shop'])) {
$sql->where('b.`id_shop` = ' . (int)$id_shop);
}
}

// Get shop informations
if (Shop::isTableAssociated($entity_defs['table'])) {
$sql->leftJoin($entity_defs['table'] . '_shop', 'c', 'a.`' . bqSQL($entity_defs['primary']) . '` = c.`' . bqSQL($entity_defs['primary']) . '` AND c.`id_shop` = ' . (int)$id_shop);
}

if ($object_datas = Db::getInstance()->getRow($sql)) {
if (!$id_lang && isset($entity_defs['multilang']) && $entity_defs['multilang']) {
$sql = 'SELECT *
FROM `' . bqSQL(_DB_PREFIX_ . $entity_defs['table']) . '_lang`
WHERE `' . bqSQL($entity_defs['primary']) . '` = ' . (int)$id
.(($id_shop && $entity->isLangMultishop()) ? ' AND `id_shop` = ' . (int)$id_shop : '');

if ($object_datas_lang = Db::getInstance()->executeS($sql)) {
foreach ($object_datas_lang as $row) {
foreach ($row as $key => $value) {
if ($key != $entity_defs['primary'] && array_key_exists($key, $entity)) {
if (!isset($object_datas[$key]) || !is_array($object_datas[$key])) {
$object_datas[$key] = array();
}

$object_datas[$key][$row['id_lang']] = $value;
}
}
}
}
}
$entity->id = (int)$id;
foreach ($object_datas as $key => $value) {
if (array_key_exists($key, $entity)) {
$entity->{$key} = $value;
} else {
unset($object_datas[$key]);
}
}
if ($should_cache_objects) {
Cache::store($cache_id, $object_datas);
}
}
} else {
$object_datas = Cache::retrieve($cache_id);
if ($object_datas) {
$entity->id = (int)$id;
foreach ($object_datas as $key => $value) {
$entity->{$key} = $value;
}
}
}
}
}
51 changes: 51 additions & 0 deletions Adapter/Adapter_EntityMetaDataRetriever.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

class Adapter_EntityMetaDataRetriever
{
public function getEntityMetaData($className)
{
$metaData = new Core_Foundation_Database_EntityMetaData;

$metaData->setEntityClassName($className);

if (property_exists($className, 'definition')) {
// Legacy entity
$classVars = get_class_vars($className);
$metaData->setTableName($classVars['definition']['table']);
$metaData->setPrimaryKeyFieldNames(array($classVars['definition']['primary']));
} else {
throw new Adapter_Exception(
sprintf(
'Cannot get metadata for entity `%s`.',
$className
)
);
}

return $metaData;
}
}
Loading

0 comments on commit abb42e6

Please sign in to comment.