<?php
namespace Moto\Application\Theme; use Moto; class Service extends Moto\Service\AbstractStaticService { protected static $_resourceName = 'theme'; protected static $_resourcePrivilegesMap = array( 'getSpacings' => 'get', 'setSpacings' => 'set', 'getGridOptions' => 'get', 'setGridOptions' => 'set', 'setHeadingSpacings' => 'set', 'getHeadingSpacings' => 'get', ); public static function getSpacings() { $result = Moto\Website\Settings::get('spacings', array( 'desktop' => array( 'small' => 10, 'medium' => 20, 'large' => 30, ), 'tablet' => array( 'small' => 10, 'medium' => 20, 'large' => 30, ), 'mobile-h' => array( 'small' => 10, 'medium' => 20, 'large' => 30, ), 'mobile-v' => array( 'small' => 10, 'medium' => 20, 'large' => 30, ), )); if (is_string($result)) { $result = json_decode($result); } return $result; } public static function setSpacings($request = null) { if (null === $request) $request = static::getRequest()->getParams(); if (empty($request)) { return false; } $data = json_encode($request); Moto\Website\Settings::set('spacings', $data); Moto\System\Style::rebuildAll(); return $request; } public static function getGridOptions() { return Moto\Website\Settings::get('theme_grid', array()); } public static function setGridOptions($request = null) { if (null === $request) $request = static::getRequest()->getParams(); $filter = new Moto\Application\Theme\InputFilter\UpdateGridOption(); $filter->setData($request); if (!$filter->isValid()) { throw new Moto\Json\Server\Exception(Moto\System\Exception::ERROR_BAD_REQUEST_MESSAGE, Moto\System\Exception::ERROR_BAD_REQUEST_CODE, $filter->getMessagesKeys()); } $values = $filter->getValues(); if (!Moto\Website\Settings::add('theme_grid', $values, 'array')) { Moto\Website\Settings::set('theme_grid', $values); } Moto\System\Style::rebuildAll(); return $values; } public static function getHeadingSpacings() { $response = Moto\Website\Settings::get('theme_headings'); if (!$response) { $response = Moto\Website\Theme::getDefaultValue('headings'); } return $response; } public static function setHeadingSpacings($request = null) { if (null === $request) { $request = static::getRequest()->getParams(); } if (empty($request)) { return false; } Moto\Website\Settings::add('theme_headings', $request, 'object'); Moto\System\Style::rebuildAll(); return $request; } } 