$siteStyle->setAttribute('current_version', $currentVersion + 1); $siteStyle->store(); // Create a new version $siteStyleVersion = new ezcsseSiteStyleVersion(); $siteStyleVersion->setAttribute('sitestyle_id', $siteStyle->attribute('id')); $siteStyleVersion->setAttribute('version', $currentVersion + 1); $siteStyleVersion->setAttribute('created', time()); $siteStyleVersion->setAttribute('modified', time()); $siteStyleVersion->store(); $siteStyleDef = new ezcsseSiteStyleDefinition(); $siteStyleDef->setAttribute('sitestyle_id', $siteStyle->attribute('id')); $siteStyleDef->setAttribute('version', $currentVersion + 1); $siteStyleDef->setAttribute('style', $style); $siteStyleDef->store(); } else { $siteStyle = new ezcsseSiteStyle(); $siteStyle->setAttribute('name', 'New style'); $siteStyle->setAttribute('current_version', 1); $siteStyle->setAttribute('selected', 1); $siteStyle->store(); $siteStyleVersion = new ezcsseSiteStyleVersion(); $siteStyleVersion->setAttribute('sitestyle_id', $siteStyle->attribute('id')); $siteStyleVersion->setAttribute('version', 1); $siteStyleVersion->setAttribute('created', time()); $siteStyleVersion->setAttribute('modified', time()); $siteStyleVersion->store(); $siteStyleDef = new ezcsseSiteStyleDefinition(); $siteStyleDef->setAttribute('sitestyle_id', $siteStyle->attribute('id')); $siteStyleDef->setAttribute('version', 1); $siteStyleDef->store(); }
/** * Fetches currently selected site style object * * @return array */ public static function fetchCurrentSiteStyle() { $siteStyle = ezcsseSiteStyle::fetchObject(ezcsseSiteStyle::definition(), null, array('selected' => 1)); return array('result' => $siteStyle); }
/** * Fetches ezcsseSiteStyle object by given ID * * @param integer $id * @return ezcsseSiteStyle */ public static function fetch($id) { $siteStyle = ezcsseSiteStyle::fetchObject(ezcsseSiteStyle::definition(), null, array('id' => $id)); return $siteStyle; }
/** * Returns the ezcsseSiteStyleDefinition object * * @static * @return ezcsseSiteStyleDefinition */ public static function getStyleDefinition() { $siteStyle = ezcsseSiteStyle::fetchObject(ezcsseSiteStyle::definition(), null, array('selected' => 1)); $version = $siteStyle->attribute('version'); $styleDefinition = $siteStyle->attribute('style'); return $styleDefinition; }