Пример #1
0
 /**
  * Get recordset of all selected wallpaper
  *
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Data_RecordSet
  */
 public function loadSelectedWallpaperNoRpc()
 {
     $response = new Gpf_Data_RecordSet();
     $response->addColumn(self::WALLPAPER_TYPE);
     $response->addColumn(self::WALLPAPER_POSITION);
     $response->addColumn(self::BACKGROUND_COLOR);
     $response->addColumn("fileId");
     $response->addColumn("url");
     $record = $response->createRecord();
     try {
         Gpf_Db_Table_UserAttributes::getInstance()->loadAttributes(Gpf_Session::getAuthUser()->getAccountUserId());
         $wallpaperType = Gpf_Db_Table_UserAttributes::getInstance()->getAttributeWithDefaultValue(self::WALLPAPER_TYPE, self::TYPE_THEME);
         $theme = new Gpf_Desktop_Theme();
         $wallpaperId = Gpf_Db_Table_UserAttributes::getInstance()->getAttributeWithDefaultValue(self::WALLPAPER, $theme->getDefaultWallpaper());
         $position = Gpf_Db_Table_UserAttributes::getInstance()->getAttributeWithDefaultValue(self::WALLPAPER_POSITION, $theme->getDefaultWallpaperPosition());
         $color = Gpf_Db_Table_UserAttributes::getInstance()->getAttributeWithDefaultValue(self::BACKGROUND_COLOR, $theme->getDefaultBackgroundColor());
         $record->set(self::WALLPAPER_POSITION, $position);
         $record->set(self::BACKGROUND_COLOR, $color);
         $record->set(self::WALLPAPER_TYPE, $wallpaperType);
         if ($wallpaperType == self::TYPE_THEME) {
             $record->set("url", Gpf_Paths::getInstance()->getResourceUrl($wallpaperId, Gpf_Paths::IMAGE_DIR . Gpf_Paths::WALLPAPER_DIR));
         } else {
             if ($wallpaperType == self::TYPE_CUSTOM) {
                 $wallpaper = new Gpf_Db_Wallpaper();
                 $wallpaper->setPrimaryKeyValue($wallpaperId);
                 $wallpaper->load();
                 $record->set("fileId", $wallpaper->getFileId());
                 $record->set("url", $wallpaper->getUrl());
             }
         }
     } catch (Gpf_Exception $e) {
         $theme = new Gpf_Desktop_Theme();
         $record->set(self::WALLPAPER_POSITION, "S");
         $record->set(self::BACKGROUND_COLOR, "#000000");
         $record->set(self::WALLPAPER_TYPE, self::TYPE_NONE);
         $record->set("fileId", null);
         $record->set("url", "");
     }
     $response->addRecord($record);
     return $response;
 }