PageRenderTime 28ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/Varien/Db/Helper.php

https://github.com/speedupmate/Magento-CE-Mirror
PHP | 110 lines | 58 code | 4 blank | 48 comment | 0 complexity | c5d175b07eed829c30ce79f80776b17a MD5 | raw file
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magento.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magento.com for more information.
  20. *
  21. * @category Varien
  22. * @package Varien_Db
  23. * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. /**
  27. * Varien Db Helper
  28. *
  29. * @category Varien
  30. * @package Varien_Db
  31. * @author Magento Core Team <core@magentocommerce.com>
  32. */
  33. class Varien_Db_Helper
  34. {
  35. /**
  36. * Dictionary for generate short name
  37. *
  38. * @var array
  39. */
  40. protected static $_translateMap = array(
  41. 'address' => 'addr',
  42. 'admin' => 'adm',
  43. 'attribute' => 'attr',
  44. 'enterprise' => 'ent',
  45. 'catalog' => 'cat',
  46. 'category' => 'ctgr',
  47. 'customer' => 'cstr',
  48. 'notification' => 'ntfc',
  49. 'product' => 'prd',
  50. 'session' => 'sess',
  51. 'user' => 'usr',
  52. 'entity' => 'entt',
  53. 'datetime' => 'dtime',
  54. 'decimal' => 'dec',
  55. 'varchar' => 'vchr',
  56. 'index' => 'idx',
  57. 'compare' => 'cmp',
  58. 'bundle' => 'bndl',
  59. 'option' => 'opt',
  60. 'gallery' => 'glr',
  61. 'media' => 'mda',
  62. 'value' => 'val',
  63. 'link' => 'lnk',
  64. 'title' => 'ttl',
  65. 'super' => 'spr',
  66. 'label' => 'lbl',
  67. 'website' => 'ws',
  68. 'aggregat' => 'aggr',
  69. 'minimal' => 'min',
  70. 'inventory' => 'inv',
  71. 'status' => 'sts',
  72. 'agreement' => 'agrt',
  73. 'layout' => 'lyt',
  74. 'resource' => 'res',
  75. 'directory' => 'dir',
  76. 'downloadable' => 'dl',
  77. 'element' => 'elm',
  78. 'fieldset' => 'fset',
  79. 'checkout' => 'chkt',
  80. 'newsletter' => 'nlttr',
  81. 'shipping' => 'shpp',
  82. 'calculation' => 'calc',
  83. 'search' => 'srch',
  84. 'query' => 'qr'
  85. );
  86. /**
  87. * Convert name using dictionary
  88. *
  89. * @param string $name
  90. * @return string
  91. */
  92. public static function shortName($name)
  93. {
  94. return strtr($name, self::$_translateMap);
  95. }
  96. /**
  97. * Add or replace translate to dictionary
  98. *
  99. * @param string $from
  100. * @param string $to
  101. */
  102. public static function addTranslate($from, $to)
  103. {
  104. self::$_translateMap[$from] = $to;
  105. }
  106. }