PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/app/code/core/Mage/XmlConnect/Helper/Image.php

https://bitbucket.org/claudiu_marginean/magento-hg-mirror
PHP | 731 lines | 441 code | 59 blank | 231 comment | 78 complexity | 2a8951cb90ae37ce3a3e8d366aac4bb1 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, LGPL-2.1, GPL-2.0, WTFPL
  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@magentocommerce.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.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_XmlConnect
  23. * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. class Mage_XmlConnect_Helper_Image extends Mage_Core_Helper_Abstract
  27. {
  28. const XMLCONNECT_GLUE = '_';
  29. /**
  30. * Image limits for content
  31. *
  32. * @var array|null
  33. */
  34. protected $_content = null;
  35. /**
  36. * Image limits for interface
  37. *
  38. * @var array|null
  39. */
  40. protected $_interface = null;
  41. /**
  42. * Array of interface image paths in xmlConfig
  43. *
  44. * @var array
  45. */
  46. protected $_interfacePath = array();
  47. /**
  48. * Image limits array
  49. *
  50. * @var array
  51. */
  52. protected $_imageLimits = array();
  53. /**
  54. * Images paths in the config
  55. *
  56. * @var array|null
  57. */
  58. protected $_confPaths = null;
  59. /**
  60. * Process uploaded file
  61. * setup filenames to the configuration
  62. *
  63. * @param string $field
  64. * @param mixed &$target
  65. * @retun string
  66. */
  67. public function handleUpload($field, &$target)
  68. {
  69. $uploadedFilename = '';
  70. $uploadDir = $this->getOriginalSizeUploadDir();
  71. try {
  72. $this->_forcedConvertPng($field);
  73. /** @var $uploader Mage_Core_Model_File_Uploader */
  74. $uploader = Mage::getModel('core/file_uploader', $field);
  75. $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
  76. $uploader->setAllowRenameFiles(true);
  77. $uploader->save($uploadDir);
  78. $uploadedFilename = $uploader->getUploadedFileName();
  79. $uploadedFilename = $this->_getResizedFilename($field, $uploadedFilename, true);
  80. } catch (Exception $e) {
  81. /**
  82. * Hard coded exception catch
  83. */
  84. if (!strlen($_FILES[$field]['tmp_name'])) {
  85. Mage::throwException(Mage::helper('xmlconnect')->__('File can\'t be uploaded.'));
  86. } elseif ($e->getMessage() == 'Disallowed file type.') {
  87. $filename = $_FILES[$field]['name'];
  88. Mage::throwException(Mage::helper('xmlconnect')->__('Error while uploading file "%s". Disallowed file type. Only "jpg", "jpeg", "gif", "png" are allowed.', $filename));
  89. } else {
  90. Mage::logException($e);
  91. }
  92. }
  93. return $uploadedFilename;
  94. }
  95. /**
  96. * Return current screen_size parameter
  97. *
  98. * @return string
  99. */
  100. protected function _getScreenSize()
  101. {
  102. return Mage::helper('xmlconnect')->getApplication()->getScreenSize();
  103. }
  104. /**
  105. * Return correct system filename for current screenSize
  106. *
  107. * @throws Mage_Core_Exception
  108. * @param string $fieldPath
  109. * @param string $fileName
  110. * @param string $default
  111. * @return string
  112. */
  113. protected function _getResizedFilename($fieldPath, $fileName, $default = false)
  114. {
  115. $fileName = basename($fileName);
  116. if ($default) {
  117. $dir = $this->getDefaultSizeUploadDir();
  118. } else {
  119. $dir = $this->getCustomSizeUploadDir($this->_getScreenSize());
  120. }
  121. $customSizeFileName = $dir . DS . $fileName;
  122. $originalSizeFileName = $this->getOriginalSizeUploadDir(). DS . $fileName;
  123. $error = false;
  124. /**
  125. * Compatibility with old versions of XmlConnect
  126. */
  127. if (!file_exists($originalSizeFileName)) {
  128. $oldFileName = $this->getOldUploadDir() . DS . $fileName;
  129. if (file_exists($oldFileName)) {
  130. if (!(copy($oldFileName, $originalSizeFileName) &&
  131. (is_readable($customSizeFileName) || chmod($customSizeFileName, 0644)))) {
  132. Mage::throwException(Mage::helper('xmlconnect')->__('Error while processing file "%s".', $fileName));
  133. }
  134. } else {
  135. Mage::throwException(Mage::helper('xmlconnect')->__('No such file "%s".', $fileName));
  136. }
  137. }
  138. if ((!$error) && copy($originalSizeFileName, $customSizeFileName) &&
  139. (is_readable($customSizeFileName) || chmod($customSizeFileName, 0644))) {
  140. $this->_handleResize($fieldPath, $customSizeFileName);
  141. } else {
  142. $fileName = '';
  143. if (isset($_FILES[$fieldPath]) && is_array($_FILES[$fieldPath]) && isset($_FILES[$fieldPath]['name'])) {
  144. $fileName = $_FILES[$fieldPath]['name'];
  145. }
  146. Mage::throwException(Mage::helper('xmlconnect')->__('Error while uploading file "%s".', $fileName));
  147. }
  148. return $customSizeFileName;
  149. }
  150. /**
  151. * Resize uploaded file
  152. *
  153. * @param string $fieldPath
  154. * @param string $file
  155. * @return void
  156. */
  157. protected function _handleResize($fieldPath, $file)
  158. {
  159. $nameParts = explode('/', $fieldPath);
  160. array_shift($nameParts);
  161. $conf = $this->getInterfaceImageLimits();
  162. while (count($nameParts)) {
  163. $next = array_shift($nameParts);
  164. if (isset($conf[$next])) {
  165. $conf = $conf[$next];
  166. } else {
  167. /**
  168. * No config data - nothing to resize
  169. */
  170. return;
  171. }
  172. }
  173. $image = new Varien_Image($file);
  174. $width = $image->getOriginalWidth();
  175. $height = $image->getOriginalHeight();
  176. if (isset($conf['widthMax']) && ($conf['widthMax'] < $width)) {
  177. $width = $conf['widthMax'];
  178. } elseif (isset($conf['width'])) {
  179. $width = $conf['width'];
  180. }
  181. if (isset($conf['heightMax']) && ($conf['heightMax'] < $height)) {
  182. $height = $conf['heightMax'];
  183. } elseif (isset($conf['height'])) {
  184. $height = $conf['height'];
  185. }
  186. if (($width != $image->getOriginalWidth()) ||
  187. ($height != $image->getOriginalHeight()) ) {
  188. $image->keepTransparency(true);
  189. $image->keepFrame(true);
  190. $image->keepAspectRatio(true);
  191. $image->backgroundColor(array(255, 255, 255));
  192. $image->resize($width, $height);
  193. $image->save(null, basename($file));
  194. }
  195. }
  196. /**
  197. * Convert uploaded file to PNG
  198. *
  199. * @param string $field
  200. */
  201. protected function _forcedConvertPng($field)
  202. {
  203. $file =& $_FILES[$field];
  204. $file['name'] = preg_replace('/\.(gif|jpeg|jpg)$/i', '.png', $file['name']);
  205. list($x, $x, $fileType) = getimagesize($file['tmp_name']);
  206. if ($fileType != IMAGETYPE_PNG ) {
  207. switch( $fileType ) {
  208. case IMAGETYPE_GIF:
  209. $img = imagecreatefromgif($file['tmp_name']);
  210. break;
  211. case IMAGETYPE_JPEG:
  212. $img = imagecreatefromjpeg($file['tmp_name']);
  213. break;
  214. default:
  215. return;
  216. }
  217. imagealphablending($img, false);
  218. imagesavealpha($img, true);
  219. imagepng($img, $file['tmp_name']);
  220. imagedestroy($img);
  221. }
  222. }
  223. /**
  224. * Retrieve xmlconnect images skin url
  225. *
  226. * @param string $name
  227. * @return string
  228. */
  229. public function getSkinImagesUrl($name = null)
  230. {
  231. return Mage::getDesign()->getSkinUrl('images/xmlconnect/' . $name);
  232. }
  233. /**
  234. * Return CustomSizeDirPrefix
  235. *
  236. * @return string
  237. */
  238. public function getCustomSizeDirPrefix()
  239. {
  240. return $this->_getScreenSize() . DS . 'custom';
  241. }
  242. /**
  243. * Return FileDefaultSizeSuffixAsUrl
  244. *
  245. * @param string $fileName
  246. * @return string
  247. */
  248. public function getFileDefaultSizeSuffixAsUrl($fileName)
  249. {
  250. return 'custom'.'/'.$this->_getScreenSize().'/'.basename($fileName);
  251. }
  252. /**
  253. * Return getFileCustomDirSuffixAsUrl
  254. *
  255. * @param string $confPath
  256. * @param string $fileName
  257. * @return string
  258. */
  259. public function getFileCustomDirSuffixAsUrl($confPath, $fileName)
  260. {
  261. return 'custom'.'/'.$this->_getScreenSize().'/'.basename($this->_getResizedFilename($confPath, $fileName));
  262. }
  263. /**
  264. * Return correct size for given $imageName and device screen_size
  265. *
  266. * @param string $imageName
  267. * @return int
  268. */
  269. public function getImageSizeForContent($imageName)
  270. {
  271. $size = 0;
  272. if (!isset($this->_content)) {
  273. /** @var $app Mage_XmlConnect_Model_Application */
  274. $app = Mage::helper('xmlconnect')->getApplication();
  275. $imageLimits = $this->getImageLimits($this->_getScreenSize());
  276. if (($imageLimits['content']) && is_array($imageLimits['content'])) {
  277. $this->_content = $imageLimits['content'];
  278. } else {
  279. $this->_content = array();
  280. }
  281. }
  282. $size = isset($this->_content[$imageName]) ? (int) $this->_content[$imageName] : 0;
  283. return $size;
  284. }
  285. /**
  286. * Return setting for interface images (image size limits)
  287. *
  288. * @return array
  289. */
  290. public function getInterfaceImageLimits()
  291. {
  292. if (!isset($this->_interface)) {
  293. $imageLimits = $this->getImageLimits($this->_getScreenSize());
  294. $this->_interface = $imageLimits['interface'];
  295. }
  296. return $this->_interface;
  297. }
  298. /**
  299. * Return correct size for given $imageName and device screen_size
  300. *
  301. * @param string $imagePath
  302. * @return int
  303. */
  304. public function getImageSizeForInterface($imagePath)
  305. {
  306. $size = 0;
  307. if (!isset($this->_interfacePath[$imagePath])) {
  308. $app = Mage::helper('xmlconnect')->getApplication();
  309. if (!$app) {
  310. return 0;
  311. } else {
  312. $imageLimits = $this->getImageLimits($this->_getScreenSize());
  313. $size = $this->findPath($imageLimits, $imagePath);
  314. $this->_interfacePath[$imagePath] = $size;
  315. }
  316. }
  317. $size = isset($this->_interfacePath[$imagePath]) ? (int) $this->_interfacePath[$imagePath] : 0;
  318. return $size;
  319. }
  320. /**
  321. * Return the filesystem path to XmlConnect media files
  322. *
  323. * @param string $path Right part of the path
  324. * @return string
  325. */
  326. public function getMediaPath($path = '')
  327. {
  328. $path = trim($path);
  329. $result = Mage::getBaseDir('media') . DS . 'xmlconnect';
  330. if (!empty($path)) {
  331. if (strpos($path, DS) === 0) {
  332. $path = substr($path, 1);
  333. }
  334. $result .= DS . $path;
  335. }
  336. return $result;
  337. }
  338. /**
  339. * Return Url for media image
  340. *
  341. * @param string $image
  342. * @return string
  343. */
  344. public function getMediaUrl($image = '')
  345. {
  346. $image = trim($image);
  347. $result = Mage::getBaseUrl('media') . 'xmlconnect';
  348. if (!empty($image)) {
  349. if (strpos($image, '/') === 0) {
  350. $image = substr($image, 1);
  351. }
  352. $result .= '/' . $image;
  353. }
  354. return $result;
  355. }
  356. /**
  357. * Return URL for default design image
  358. *
  359. * @param string $image
  360. * @return string
  361. */
  362. public function getDefaultDesignUrl($image = '')
  363. {
  364. return $this->getSkinImagesUrl($this->getDefaultDesignSuffixAsUrl($image));
  365. }
  366. /**
  367. * Return suffix as URL for default design image
  368. *
  369. * @param string $image
  370. * @return string
  371. */
  372. public function getDefaultDesignSuffixAsUrl($image = '')
  373. {
  374. return 'design_default/' . trim(ltrim($image, '/'));
  375. }
  376. /**
  377. * Retrieve thumbnail image url
  378. *
  379. * @param int $width
  380. * @return string|null
  381. */
  382. public function getCustomSizeImageUrl($imageUrl, $width = 100, $height = 100)
  383. {
  384. $customDirRoot = Mage::getBaseDir('media') . DS . 'xmlconnect' . DS . 'custom';
  385. $screenSize = $width . 'x' . $height;
  386. $customDir = $customDirRoot . DS . $screenSize;
  387. $this->_verifyDirExist($customDir);
  388. $imageUrl = explode('/', $imageUrl);
  389. $file = $imageUrl[count($imageUrl)-1];
  390. $filePath = $this->getDefaultSizeUploadDir() . DS . $file;
  391. if (!file_exists($customDir . $file)) {
  392. $image = new Varien_Image($filePath);
  393. $widthOriginal = $image->getOriginalWidth();
  394. $heightOriginal = $image->getOriginalHeight();
  395. if ($width != $widthOriginal) {
  396. $widthOriginal = $width;
  397. }
  398. if ($height != $heightOriginal) {
  399. $heightOriginal = $height;
  400. }
  401. if (($widthOriginal != $image->getOriginalWidth()) ||
  402. ($heightOriginal != $image->getOriginalHeight()) ) {
  403. $image->keepTransparency(true);
  404. $image->keepFrame(true);
  405. $image->keepAspectRatio(true);
  406. $image->backgroundColor(array(255, 255, 255));
  407. $image->resize($widthOriginal, $heightOriginal);
  408. $image->save($customDir, basename($file));
  409. }
  410. }
  411. return Mage::getBaseUrl('media') . "xmlconnect/custom/{$screenSize}/" . basename($file);
  412. }
  413. /**
  414. * Ensure correct $screenSize value
  415. *
  416. * @param string $screenSize
  417. * @return string
  418. */
  419. public function filterScreenSize($screenSize)
  420. {
  421. $screenSize = preg_replace('/[^0-9A-z_]/', '', $screenSize);
  422. if (isset($this->_imageLimits[$screenSize])) {
  423. return $screenSize;
  424. }
  425. $screenSizeExplodeArray = explode(self::XMLCONNECT_GLUE, $screenSize);
  426. $version = '';
  427. switch (count($screenSizeExplodeArray)) {
  428. case 2:
  429. $version = $screenSizeExplodeArray[1];
  430. case 1:
  431. $resolution = $screenSizeExplodeArray[0];
  432. break;
  433. default:
  434. $resolution = Mage_XmlConnect_Model_Application::APP_SCREEN_SIZE_DEFAULT;
  435. break;
  436. }
  437. $sourcePath = empty($version) ? Mage_XmlConnect_Model_Application::APP_SCREEN_SOURCE_DEFAULT : $version;
  438. $xmlPath = 'screen_size/'.self::XMLCONNECT_GLUE.$resolution.'/'.$sourcePath.'/source';
  439. $source = Mage::getStoreConfig($xmlPath);
  440. if (!empty($source)) {
  441. $screenSize = $resolution . (empty($version) ? '' : self::XMLCONNECT_GLUE.$version);
  442. } else {
  443. $screenSize = Mage_XmlConnect_Model_Application::APP_SCREEN_SIZE_DEFAULT;
  444. }
  445. return $screenSize;
  446. }
  447. /**
  448. * Return correct size array for given device screen_size(320x480/640x960_a)
  449. *
  450. * @param string $screenSize
  451. * @return array
  452. */
  453. public function getImageLimits($screenSize = Mage_XmlConnect_Model_Application::APP_SCREEN_SIZE_DEFAULT)
  454. {
  455. $defaultScreenSize = Mage_XmlConnect_Model_Application::APP_SCREEN_SIZE_DEFAULT;
  456. $defaultScreenSource = Mage_XmlConnect_Model_Application::APP_SCREEN_SOURCE_DEFAULT;
  457. $screenSize = preg_replace('/[^0-9A-z_]/', '', $screenSize);
  458. if (isset($this->_imageLimits[$screenSize])) {
  459. return $this->_imageLimits[$screenSize];
  460. }
  461. $screenSizeExplodeArray = explode(self::XMLCONNECT_GLUE, $screenSize);
  462. $version = '';
  463. switch (count($screenSizeExplodeArray)) {
  464. case 2:
  465. $version = $screenSizeExplodeArray[1];
  466. case 1:
  467. $resolution = $screenSizeExplodeArray[0];
  468. break;
  469. default:
  470. $resolution = $defaultScreenSize;
  471. break;
  472. }
  473. $sourcePath = empty($version) ? $defaultScreenSource : $version;
  474. $xmlPath = 'screen_size/'.self::XMLCONNECT_GLUE.$resolution.'/'.$sourcePath;
  475. $root = Mage::getStoreConfig($xmlPath);
  476. $updates = array();
  477. if (!empty($root)) {
  478. $screenSize = $resolution . (empty($version) ? '' : self::XMLCONNECT_GLUE.$version);
  479. $source = !empty($root['source']) ? $root['source'] : $defaultScreenSource;
  480. $updates = isset($root['updates']) && is_array($root['updates']) ? $root['updates'] : array();
  481. } else {
  482. $screenSize = $defaultScreenSize;
  483. $source = $defaultScreenSource;
  484. }
  485. $imageLimits = Mage::getStoreConfig('screen_size/'.$source);
  486. if (!is_array($imageLimits)) {
  487. $imageLimits = Mage::getStoreConfig('screen_size/default');
  488. }
  489. foreach ($updates as $update) {
  490. $path = $update['path'];
  491. $function = $update['function'];
  492. switch ($function) {
  493. case 'zoom':
  494. $data = $update['data'];
  495. $target =& $this->findPath($imageLimits, $path);
  496. if (is_array($target)) {
  497. array_walk_recursive($target, array($this, '_zoom'), $data);
  498. } else {
  499. $this->_zoom($target, null, $data);
  500. }
  501. break;
  502. case 'update':
  503. $data = $update['data'];
  504. $target =& $this->findPath($imageLimits, $path);
  505. $target = $data;
  506. break;
  507. case 'insert':
  508. $data = $update['data'];
  509. $target =& $this->findPath($imageLimits, $path);
  510. if (($target !== null) && (is_array($target)) && (is_array($data))) {
  511. foreach ($data as $key => $val) {
  512. $target[$key] = $val;
  513. }
  514. }
  515. break;
  516. case 'delete':
  517. $data = $update['data'];
  518. $target =& $this->findPath($imageLimits, $path);
  519. if (isset($target[$data])) {
  520. unset($target[$data]);
  521. }
  522. break;
  523. default:
  524. break;
  525. }
  526. }
  527. if (!is_array($imageLimits)) {
  528. $imageLimits = array();
  529. }
  530. $this->_imageLimits[$screenSize] = $imageLimits;
  531. return $imageLimits;
  532. }
  533. /**
  534. * Return reference to the $path in $array
  535. *
  536. * @param array $array
  537. * @param string $path
  538. * @return &mixed //(reference)
  539. */
  540. public function &findPath(&$array, $path)
  541. {
  542. $target =& $array;
  543. if ($path !== '/') {
  544. $pathArray = explode('/', $path);
  545. foreach ($pathArray as $node) {
  546. if (is_array($target) && isset($target[$node])) {
  547. $target =& $target[$node];
  548. } else {
  549. $targetNull = null;
  550. return $targetNull;
  551. }
  552. }
  553. }
  554. return $target;
  555. }
  556. /**
  557. * Multiply given $item by $value if non array
  558. *
  559. * @param mixed $item (argument to change)
  560. * @param mixed $key (not used)
  561. * @param string $value (contains float)
  562. * @return void
  563. */
  564. protected function _zoom(&$item, $key, $value)
  565. {
  566. if (is_string($item)) {
  567. $item = (int) round($item*$value);
  568. }
  569. }
  570. /**
  571. * Ensure $dir exists (if not then create one)
  572. *
  573. * @param string $dir
  574. * @throw Mage_Core_Exception
  575. */
  576. protected function _verifyDirExist($dir)
  577. {
  578. $io = new Varien_Io_File();
  579. $io->checkAndCreateFolder($dir);
  580. }
  581. /**
  582. * Return customSizeUploadDir path
  583. *
  584. * @param string $screenSize
  585. * @return string
  586. */
  587. public function getCustomSizeUploadDir($screenSize)
  588. {
  589. $screenSize = $this->filterScreenSize($screenSize);
  590. $customDirRoot = Mage::getBaseDir('media') . DS . 'xmlconnect' . DS . 'custom';
  591. $this->_verifyDirExist($customDirRoot);
  592. $customDir = $customDirRoot . DS .$screenSize;
  593. $this->_verifyDirExist($customDir);
  594. return $customDir;
  595. }
  596. /**
  597. * Return originalSizeUploadDir path
  598. *
  599. * @return string
  600. */
  601. public function getOriginalSizeUploadDir()
  602. {
  603. $dir = Mage::getBaseDir('media') . DS . 'xmlconnect' . DS . 'original';
  604. $this->_verifyDirExist($dir);
  605. return $dir;
  606. }
  607. /**
  608. * Return oldUpload dir path (media/xmlconnect)
  609. *
  610. * @return string
  611. */
  612. public function getOldUploadDir()
  613. {
  614. $dir = Mage::getBaseDir('media') . DS . 'xmlconnect';
  615. $this->_verifyDirExist($dir);
  616. return $dir;
  617. }
  618. /**
  619. * Return default size upload dir path
  620. *
  621. * @return string
  622. */
  623. public function getDefaultSizeUploadDir()
  624. {
  625. return $this->getCustomSizeUploadDir(Mage_XmlConnect_Model_Application::APP_SCREEN_SIZE_DEFAULT);
  626. }
  627. /**
  628. * Return array for interface images paths in the config
  629. *
  630. * @return array
  631. */
  632. public function getInterfaceImagesPathsConf()
  633. {
  634. if (!isset($this->_confPaths)) {
  635. $paths = $this->getInterfaceImagesPaths();
  636. $this->_confPaths = array();
  637. $len = strlen('conf/native/');
  638. foreach ($paths as $path => $defaultFileName) {
  639. $this->_confPaths[$path] = substr($path, $len);
  640. }
  641. }
  642. return $this->_confPaths;
  643. }
  644. /**
  645. * Return 1) default interface image path for specified $imagePath
  646. * 2) array of image paths
  647. *
  648. * @param string $imagePath
  649. * @return array|string
  650. */
  651. public function getInterfaceImagesPaths($imagePath = null)
  652. {
  653. $paths = array (
  654. 'conf/native/navigationBar/icon' => 'smallIcon_1_6.png',
  655. 'conf/native/body/bannerImage' => 'banner_1_2.png',
  656. 'conf/native/body/bannerIpadImage' => 'banner_ipad.png',
  657. 'conf/native/body/bannerAndroidImage' => 'banner_android.png',
  658. 'conf/native/body/backgroundImage' => 'accordion_open.png',
  659. 'conf/native/body/backgroundIpadLandscapeImage' => 'accordion_open_ipad_l.png',
  660. 'conf/native/body/backgroundIpadPortraitImage' => 'accordion_open_ipad_p.png',
  661. 'conf/native/body/backgroundAndroidLandscapeImage' => 'accordion_open_android_l.png',
  662. 'conf/native/body/backgroundAndroidPortraitImage' => 'accordion_open_android_p.png',
  663. );
  664. if ($imagePath == null) {
  665. return $paths;
  666. } else if (isset($paths[$imagePath])) {
  667. return $paths[$imagePath];
  668. } else {
  669. return null;
  670. }
  671. }
  672. }