当前位置: 首页>>代码示例>>PHP>>正文


PHP Options::save方法代码示例

本文整理汇总了PHP中Options::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Options::save方法的具体用法?PHP Options::save怎么用?PHP Options::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Options的用法示例。


在下文中一共展示了Options::save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addAction

 public function addAction($question_id)
 {
     $this->view->poll = Questions::findFirst($question_id);
     if ($this->request->isPost()) {
         $option = new Options();
         $option->question_id = $question_id;
         $option->option_name = $this->request->getPost('name');
         $option->vote = 0;
         $option->save();
         return $this->dispatcher->forward(array('action' => 'show', 'params' => array($question_id)));
     }
 }
开发者ID:hymns,项目名称:PhalconTutorial,代码行数:12,代码来源:PollController.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Options();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Options'])) {
         $model->attributes = $_POST['Options'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:alex-bro,项目名称:yiitest,代码行数:17,代码来源:OptionsController.php

示例3: install

    /**
     * Lilina installer
     *
     * Installs Lilina after going through many complicated checks
     *
     * @param string $sitename Name of the site
     * @param string $username Initial username of the admin user
     * @param string $password Initial password of the admin user
     * @return bool True if the installer succeeded, false otherwise
     */
    public function install($sitename, $username, $password)
    {
        require_once LILINA_INCPATH . '/core/version.php';
        $settings = $this->generate_default_settings($sitename, $username, $password);
        if (!is_writable(LILINA_PATH . '/content/system/config/') || !($settings_file = @fopen(LILINA_PATH . '/content/system/config/settings.php', 'w+'))) {
            $this->file_error_notice(LILINA_PATH . '/content/system/config/settings.php', $sitename, $username, $password);
            return false;
        }
        fputs($settings_file, $settings);
        fclose($settings_file);
        if (file_exists(LILINA_PATH . '/content/system/config/feeds.data')) {
            echo "<p>Using existing feeds data</p>\n";
        } else {
            $feeds_file = new DataHandler(LILINA_CONTENT_DIR . '/system/config/');
            $feeds_file = $feeds_file->save('feeds.json', json_encode(array()));
            if (!$feeds_file) {
                $this->file_error_notice(LILINA_PATH . '/content/system/config/feeds.json', $sitename, $username, $password);
                return false;
            }
        }
        /** Make sure it's writable now */
        if (!$this->make_writable(LILINA_PATH . '/content/system/config/feeds.json')) {
            echo "<p>Couldn't make <code>content/system/config/feeds.json</code> writable. Please ensure you make it writable yourself</p>\n";
        }
        default_options();
        Options::lazy_update('sitename', $sitename);
        if (!Options::save()) {
            $this->file_error_notice(LILINA_PATH . '/content/system/config/options.data', $sitename, $username, $password);
            return false;
        }
        $user = new User($username, $password);
        $user->identify();
        ?>
	<h1 id="title">Installation Complete!</h1>
	<p>Lilina has been installed and is now ready to go. Please note your username and password below, as it <strong>won't be shown again</strong>!</p>
	<dl id="logindetails">
		<dt>Your username is</dt>
		<dd id="username"><?php 
        echo $username;
        ?>
</dd>
		<dt>and your password is</dt>
		<dd id="password"><?php 
        echo $password;
        ?>
</dd>
	</dl>
	<p><a href="admin/">Head to the admin panel</a> to get started!</p>
	<?php 
        return true;
    }
开发者ID:JocelynDelalande,项目名称:Lilina,代码行数:61,代码来源:install-functions.php

示例4: save

 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // save options and affected package ids
     $saveOptions = $affectedPackageIDArray = array();
     foreach ($this->cachedOptions as $option) {
         $saveOptions[$option['optionID']] = $option['optionValue'];
         $affectedPackageIDArray[] = $option['packageID'];
     }
     Options::save($saveOptions);
     // clear cache
     Options::resetCache();
     // delete relevant options.inc.php's
     $affectedPackageIDArray = array_unique($affectedPackageIDArray);
     Options::resetFile($affectedPackageIDArray);
     $this->saved();
     // show succes message
     WCF::getTPL()->assign('success', true);
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:22,代码来源:OptionForm.class.php

示例5: importLanguage

 /**
  * Import a language
  * 
  */
 public static function importLanguage($filename, $showMessage = true, $fastImport = false)
 {
     $localErrors = array();
     $allAccounts = array();
     $dom = new domDocument();
     if (!$dom->load($filename)) {
         if ($showMessage) {
             throw new CException(Yii::t('lazy8', 'input file could not be xml parsed'));
         } else {
             throw new CException('input file could not be xml parsed');
         }
     }
     $root = $dom->documentElement;
     if ($root->nodeName != "lazy8webportlang") {
         if ($showMessage) {
             $localErrors = array(array(Yii::t('lazy8', 'Upload failed.  This is not a valid file.'), Yii::t('lazy8', 'Select a file and try again')));
         }
         $this->render('importlang');
         return $localErrors;
     }
     if ($root->getAttribute('version') > 1.0) {
         if ($showMessage) {
             $localErrors = array(array(Yii::t('lazy8', 'There maybe problems because this is a file version greater then this programs version'), Yii::t('lazy8', 'Select a file and try again')));
         }
     }
     $nodeLanguages = $root->getElementsByTagName('language');
     unset($root);
     unset($dom);
     foreach ($nodeLanguages as $nodeLanguage) {
         //make sure the company code is unique
         //Message::model()->dbConnection->createCommand("DELETE FROM Message WHERE language='".$nodeLanguage->getAttribute('langcode')."'")->execute();
         //make sure that all the source messages exist for this language
         if (!$fastImport) {
             $sources = SourceMessage::model()->findAll();
             foreach ($sources as $source) {
                 $foundMessage = Message::model()->find(array('condition' => "language='" . $nodeLanguage->getAttribute('langcode') . "' AND id=" . $source->id));
                 if ($foundMessage == null) {
                     $trans = new Message();
                     $trans->id = $source->id;
                     $trans->translation = $source->message;
                     $trans->language = $nodeLanguage->getAttribute('langcode');
                     $trans->save();
                 }
             }
         } else {
             //quickly delete all occurances of this language
             SourceMessage::model()->dbConnection->createCommand("DELETE FROM Message WHERE language='{$nodeLanguage->getAttribute('langcode')}'")->execute();
         }
         //update the version information
         if ($nodeLanguage->getAttribute('version') != null) {
             $foundOption = Options::model()->find('name=:name AND userId=:id AND companyId=:compid', array(':name' => "Language.Version." . $nodeLanguage->getAttribute('langcode'), ':id' => 0, ':compid' => 0));
             if ($foundOption !== null) {
                 $foundOption->delete();
             }
             $createOption = new Options();
             $createOption->name = "Language.Version." . $nodeLanguage->getAttribute('langcode');
             $createOption->userId = 0;
             $createOption->companyId = 0;
             $createOption->datavalue = $nodeLanguage->getAttribute('version');
             $createOption->save();
         }
         //get all the messages
         $nodeMessages = $nodeLanguage->getElementsByTagName('message');
         foreach ($nodeMessages as $nodeMessage) {
             $sources = SourceMessage::model()->find(array('condition' => "category='" . $nodeMessage->getAttribute('category') . "' AND message='" . SourceMessageController::sqlCleanString(CHtml::encode($nodeMessage->getAttribute('key'))) . "'"));
             if ($sources == null) {
                 $newSource = new SourceMessage();
                 $newSource->message = CHtml::encode($nodeMessage->getAttribute('key'));
                 $newSource->category = $nodeMessage->getAttribute('category');
                 $maxId = 0;
                 $command = SourceMessage::model()->dbConnection->createCommand("SELECT MAX(id) as maxid FROM SourceMessage");
                 try {
                     $reader = $command->query();
                 } catch (Exception $e) {
                     echo '<h2>Died on Sql Maxid</h2>';
                     throw $e;
                 }
                 if ($reader !== null && count($reader) > 0) {
                     foreach ($reader as $row) {
                         $maxId = $row['maxid'] + 1;
                         break;
                         //there is only one row here anyway.
                     }
                 }
                 $newSource->id = $maxId;
                 if ($newSource->save()) {
                     $modelMessage = new Message();
                     $modelMessage->language = $nodeLanguage->getAttribute('langcode');
                     $modelMessage->id = $newSource->id;
                     $modelMessage->translation = SourceMessageController::getNodeText($nodeMessage, "translation");
                     $modelMessage->save();
                     if (!$fastImport) {
                         //now we must add to all of the other languages.
                         $langs = Message::model()->findAll(array('select' => 'distinct language'));
                         if (isset($langs) && count($langs) > 0) {
                             foreach ($langs as $lang) {
//.........这里部分代码省略.........
开发者ID:Jride,项目名称:accounting-thaiconnections,代码行数:101,代码来源:SourceMessageController.php

示例6: setOption

 public static function setOption($name, $val)
 {
     if ($name) {
         $param = Options::model()->findByAttributes(['key' => $name]);
         if ($param) {
             $param->value = $val;
             $param->update();
             return true;
         } else {
             $param = new Options();
             $param->key = $name;
             $param->value = $val;
             $param->save();
             return true;
         }
     } else {
         return false;
     }
 }
开发者ID:alex-bro,项目名称:yiitest,代码行数:19,代码来源:Options.php

示例7: actionAddOption

 /**
  * actionAddOption
  * 
  * @access public
  * @return void
  */
 public function actionAddOption($id)
 {
     Yii::log("actionIndex OptionsController called", "trace", self::LOG_CAT);
     $model = new Options();
     $model->setCustomScenario($id);
     if (isset($_POST['Options'])) {
         $model->attributes = $_POST['Options'];
         //print_r($model); die;
         if ($model->save()) {
             Yii::app()->user->setFlash('success', "Option successfully added.");
             $this->redirect(['options/index/id/' . $id]);
         }
         if (!$model->hasErrors()) {
             Yii::app()->user->setFlash('error', "An error occurred while adding the option, please contact your administrator.");
         }
     }
     // add options via ajax from chosen plugin
     //		if(isset($_POST['options'])) {
     //			$model->setScenario($_POST['options']['scenario']);
     //			unset($_POST['options']['scenario']);
     //			$model->attributes = $_POST['options'];
     //			if($model->save()) {
     //				echo json_encode(ModelToArray::convertModelToArray($model, [$model->tableName() => 'optionId, label']));
     //				return;
     //			}
     //			$model->unsetAttributes();
     //			//print_r($model->attributeNames()); die;
     //			echo json_encode(['optionId' => '']);
     //			return;
     //
     //		}
     //		echo get_class($this->optionsMask['formFieldsModels'][$id]);
     // Select all values whose inputType is ""Select"
     $formElementsCriteria = new CDbCriteria();
     $formElementsCriteria->condition = "t.inputType='dropdownlist'";
     if ($this->optionsMask['formFieldsModels'][$id] == 'FrameworkFields') {
         //			$formElementsCriteria->join = 'LEFT JOIN parentLabel AS frameworkFields ON parentLabel.id = t.parentId';
         $formElementsCriteria->with = 'parent';
     }
     //$formElementsModel = new {$this->optionsMask['formFieldsModels'][$id]};
     $fetchOptions = CActiveRecord::model($this->optionsMask['formFieldsModels'][$id])->findAll($formElementsCriteria);
     //print_r($fetchOptions); die;
     $formElements = CHtml::listData($fetchOptions, $this->optionsMask['joinLabels'][$id][0], function ($option) use($id) {
         if (isset($option->parent)) {
             return $option->parent->label . ' - ' . $option->{$this->optionsMask['joinLabels'][$id][1]};
         }
         return $option->{$this->optionsMask['joinLabels'][$id][1]};
     });
     //print_r($formElements); die;
     $this->render('add', ['model' => $model, 'dropDownAttribute' => $this->optionsMask['relationNames'][$id] . 'Id', 'formElements' => $formElements]);
 }
开发者ID:schrapps,项目名称:risksur,代码行数:57,代码来源:OptionsController.php

示例8: save_options

/**
 * Convenience function for Options::save()
 *
 * @see Options::save()
 */
function save_options()
{
    return Options::save();
}
开发者ID:JocelynDelalande,项目名称:Lilina,代码行数:9,代码来源:class-options.php

示例9: setOptionStatesAndControlTable

 /**
  * Set the states and initialize the options table if necessary
  *  
  */
 public static function setOptionStatesAndControlTable($force, $skipDatabaseCheck, $webapp, $options, $compId, $userId)
 {
     if (!$skipDatabaseCheck) {
         foreach ($options as $key => $option) {
             $foundOption = null;
             $foundOption = Options::model()->find('name=:name AND userId=:id AND companyId=:compid', array(':name' => $key, ':id' => $userId, ':compid' => $compId));
             if ($foundOption !== null) {
                 if ($webapp->id == $userId || $force) {
                     $webapp->setState($key, User::convertOptionToObject($foundOption->datavalue, $option));
                 }
             } else {
                 $createOption = new Options();
                 $createOption->name = $key;
                 $createOption->userId = $userId;
                 $createOption->companyId = $compId;
                 $createOption->datavalue = $option[1];
                 $createOption->save();
                 if ($webapp->id == $userId || $force) {
                     $webapp->setState($key, User::convertOptionToObject($option[1], $option));
                 }
             }
         }
     } else {
         if ($webapp->id == $userId || $force) {
             //just set all company permissions to no
             foreach ($options as $key => $option) {
                 $webapp->setState($key, User::convertOptionToObject($option[2], $option));
             }
         }
     }
 }
开发者ID:Jride,项目名称:accounting-thaiconnections,代码行数:35,代码来源:User.php


注:本文中的Options::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。