Ejemplo n.º 1
0
 /**
  * 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;
 }
 /**
  * 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;
 }