Exemplo n.º 1
0
 /**
  * @see	\wcf\data\IEditableObject::create()
  */
 public static function create(array $parameters = array())
 {
     $variables = null;
     if (isset($parameters['variables'])) {
         $variables = $parameters['variables'];
         unset($parameters['variables']);
     }
     // default values
     if (!isset($parameters['packageID'])) {
         $parameters['packageID'] = 1;
     }
     if (!isset($parameters['styleDate'])) {
         $parameters['styleDate'] = gmdate('Y-m-d', TIME_NOW);
     }
     // check if no default style is defined
     $sql = "SELECT\tstyleID\n\t\t\tFROM\twcf" . WCF_N . "_style\n\t\t\tWHERE\tisDefault = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array(1));
     $row = $statement->fetchArray();
     // no default style exists
     if ($row === false) {
         $parameters['isDefault'] = 1;
     }
     // save style
     $style = parent::create($parameters);
     $styleEditor = new StyleEditor($style);
     // save variables
     if ($variables !== null) {
         $styleEditor->setVariables($variables);
     }
     // scale preview image
     if (!empty($parameters['image'])) {
         self::scalePreviewImage(WCF_DIR . $parameters['image']);
     }
     return $style;
 }
Exemplo n.º 2
0
 /**
  * @see wcf\data\IEditableObject::create()
  */
 public static function create(array $parameters = array())
 {
     $variables = null;
     if (isset($parameters['variables'])) {
         $variables = $parameters['variables'];
         unset($parameters['variables']);
     }
     // default values
     if (!isset($parameters['packageID'])) {
         $parameters['packageID'] = PACKAGE_ID;
     }
     if (!isset($parameters['styleDate'])) {
         $parameters['styleDate'] = gmdate('Y-m-d', TIME_NOW);
     }
     // save style
     $style = parent::create($parameters);
     $styleEditor = new StyleEditor($style);
     // save variables
     if ($variables !== null) {
         $styleEditor->setVariables($variables);
     }
     // scale preview image
     if (!empty($parameters['image'])) {
         self::scalePreviewImage(WCF_DIR . $parameters['image']);
     }
     return $style;
 }