/**
  * Fetches current version object
  * 
  * @return ezcsseSiteStyleVersion|null
  */
 public function fetchCurrentVersion()
 {
     $version = ezcsseSiteStyleVersion::fetchObject(ezcsseSiteStyleVersion::definition(), null, array('version' => $this->attribute('current_version'), 'sitestyle_id' => $this->attribute('id')));
     return $version;
 }
示例#2
0
    $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();
}
$tpl = templateInit();
$ini = eZINI::instance();
$http = eZHTTPTool::instance();
$contentObject = $node->attribute('object');
$nodeResult = eZNodeviewfunctions::generateNodeViewData($tpl, $node, $contentObject, $languageCode, 'full', 0);
 /**
  * Returns a JSON string with list of last versions
  * 
  * @static
  * @return string A JSON string
  */
 public static function getSiteStyleVersions()
 {
     $params = self::getPostParams();
     $siteStyleParam = isset($params['site_style']) ? $params['site_style'] : array();
     $siteStyleID = isset($siteStyleParam['id']) ? $siteStyleParam['id'] : null;
     $siteStyle = ezcsseSiteStyle::fetch($siteStyleID);
     $name = null;
     if ($siteStyle instanceof ezcsseSiteStyle) {
         $name = $siteStyle->attribute('name');
     }
     $siteStyleVersions = ezcsseSiteStyleVersion::fetchObjectList(ezcsseSiteStyleVersion::definition(), null, array('sitestyle_id' => $siteStyleID), array('id' => 'desc'), array('limit' => 10));
     $res = array();
     foreach ($siteStyleVersions as $siteStyleVersion) {
         $versionRow = array();
         $versionRow['id'] = $siteStyleVersion->attribute('id');
         $versionRow['version'] = $siteStyleVersion->attribute('version');
         $versionRow['created'] = $siteStyleVersion->attribute('created');
         $versionRow['modified'] = $siteStyleVersion->attribute('modified');
         $versionRow['name'] = $name;
         $res[] = $versionRow;
     }
     $json = json_encode($res);
     return $json;
 }