コード例 #1
0
ファイル: DbStorage.php プロジェクト: mfavetti/LimeSurvey
 /**
  * 
  * @param iPlugin $plugin
  * @param string $key
  * @param string $model Optional model name to which the data was attached.
  * @param int $id Optional id of the model instance to which the data was attached.
  * @param mixed $default Default value to return if key could not be found.
  * @return mixed Returns the value from the database or null if not set.
  */
 protected function getGeneric(iPlugin $plugin, $key, $model, $id, $default)
 {
     $attributes = array('plugin_id' => $plugin->getId(), 'model' => $model, 'model_id' => $id);
     if ($key != null) {
         $attributes['key'] = $key;
     }
     $records = \PluginSetting::model()->findAllByAttributes($attributes);
     if (count($records) > 1) {
         foreach ($records as $record) {
             $result[] = json_decode($record->value, true);
         }
     } elseif (count($records) == 1) {
         $result = json_decode($records[0]->value, true);
     } else {
         $result = $default;
     }
     return $result;
 }
コード例 #2
0
ファイル: index.php プロジェクト: ragi79/Textcube
if ($statistics->open()) {
    $writer->write('<statistics>');
    do {
        $writer->write('<daily>' . '<date>' . $statistics->datemark . '</date>' . '<visits>' . $statistics->visits . '</visits>' . '</daily>');
        $writer->write(CRLF);
    } while ($statistics->shift());
    $writer->write('</statistics>');
    $writer->write(CRLF);
    $statistics->close();
}
$setting = new SkinSetting();
if ($setting->load()) {
    $writer->write('<skin>' . '<name>' . $setting->skin . '</name>' . '<entriesOnRecent>' . $setting->entriesOnRecent . '</entriesOnRecent>' . '<commentsOnRecent>' . $setting->commentsOnRecent . '</commentsOnRecent>' . '<trackbacksOnRecent>' . $setting->trackbacksOnRecent . '</trackbacksOnRecent>' . '<commentsOnGuestbook>' . $setting->commentsOnGuestbook . '</commentsOnGuestbook>' . '<tagsOnTagbox>' . $setting->tagsOnTagbox . '</tagsOnTagbox>' . '<alignOnTagbox>' . $setting->alignOnTagbox . '</alignOnTagbox>' . '<expandComment>' . $setting->expandComment . '</expandComment>' . '<expandTrackback>' . $setting->expandTrackback . '</expandTrackback>' . '<recentNoticeLength>' . $setting->recentNoticeLength . '</recentNoticeLength>' . '<recentEntryLength>' . $setting->recentEntryLength . '</recentEntryLength>' . '<recentTrackbackLength>' . $setting->recentTrackbackLength . '</recentTrackbackLength>' . '<linkLength>' . $setting->linkLength . '</linkLength>' . '<showListOnCategory>' . $setting->showListOnCategory . '</showListOnCategory>' . '<showListOnArchive>' . $setting->showListOnArchive . '</showListOnArchive>' . '<tree>' . '<name>' . $setting->tree . '</name>' . '<color>' . $setting->colorOnTree . '</color>' . '<bgColor>' . $setting->bgcolorOnTree . '</bgColor>' . '<activeColor>' . $setting->activecolorOnTree . '</activeColor>' . '<activeBgColor>' . $setting->activebgcolorOnTree . '</activeBgColor>' . '<labelLength>' . $setting->labelLengthOnTree . '</labelLength>' . '<showValue>' . $setting->showValueOnTree . '</showValue>' . '</tree>' . '</skin>');
    $writer->write(CRLF);
}
$setting = new PluginSetting();
if ($setting->open()) {
    do {
        $writer->write('<plugin>' . '<name>' . $setting->name . '</name>' . '<setting>' . htmlspecialchars($setting->setting) . '</setting>' . '</plugin>');
        $writer->write(CRLF);
    } while ($setting->shift());
    $setting->close();
}
$setting = new UserSetting();
if ($setting->open()) {
    do {
        $writer->write('<userSetting>' . '<name>' . $setting->name . '</name>' . '<value>' . htmlspecialchars($setting->value) . '</value>' . '</userSetting>');
        $writer->write(CRLF);
    } while ($setting->shift());
    $setting->close();
}
コード例 #3
0
 /**
  * 
  * @param iPlugin $plugin
  * @param string $key
  * @param mixed data Default value to return if key could not be found.
  * @param string $model Optional model name to which the data was attached.
  * @param int $id Optional id of the model instance to which the data was attached.
  * @param string $language Optional language identifier used for storing the setting.
  * 
  * @return boolean
  */
 protected function setGeneric(iPlugin $plugin, $key, $data, $model, $id, $language)
 {
     if ($id == null && $model != null) {
         throw new Exception("DbStorage::set cannot store setting for model {$model} without valid id.");
     }
     $attributes = array('plugin_id' => $plugin->getId(), 'model' => $model, 'model_id' => $id, 'key' => $key);
     $record = PluginSetting::model()->findByAttributes($attributes);
     if (is_null($record)) {
         // New setting
         $record = PluginSetting::model()->populateRecord($attributes);
         $record->setIsNewRecord(true);
     }
     $record->value = json_encode($data);
     $result = $record->save();
     return $result;
 }