本文整理汇总了PHP中Filter::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Filter::save方法的具体用法?PHP Filter::save怎么用?PHP Filter::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter::save方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postSaveFilter
public function postSaveFilter($p, $z)
{
$filterId = $_POST['id'] ? $_POST['id'] : null;
$filter = new Filter($filterId);
if (isset($_POST['name'])) {
$filter->name = $_POST['name'];
}
$filter->content = json_encode(json_decode($_POST['content'])->subs[0]);
$filter->save();
echo json_encode(array('id' => $filter->id));
}
示例2: executeSave
public function executeSave()
{
$arr = array();
$fid = (int) mfwRequest::get('id');
if ($fid) {
$arr['id'] = $fid;
}
$arr['enable'] = (bool) mfwRequest::get('enable', true);
$arr['name'] = mfwRequest::get('name');
$arr['target'] = mfwRequest::get('target');
$arr['pattern'] = mfwRequest::get('pattern');
$filter = new Filter($arr);
$filter->save();
return $this->redirect('/filters/index');
}
示例3: isset
$quizHash = isset($_GET['quiz']) ? $_GET['quiz'] : null;
$quiz = Quiz::getByHash($quizHash);
if (empty($quiz->id) || !$quiz->hasAccess()) {
Ajax::outputError('You don\'t have access to this quiz');
}
$filter = new Filter();
$saveType = 'insert';
if (isset($_GET['filter_id']) && !empty($_GET['filter_id'])) {
$filter->readId($_GET['filter_id']);
if (empty($filter->id)) {
Ajax::outputError('Invalid filter');
}
if ($filter->quiz_id != $quiz->id) {
Ajax::outputError('Invalid filter');
}
$saveType = 'update';
}
$data = new stdClass();
$data->question = isset($_GET['question']) ? $_GET['question'] : null;
$data->answer = isset($_GET['answer']) ? $_GET['answer'] : null;
if (!empty($_GET['name'])) {
$filter->name = $_GET['name'];
}
$filter->setData($data);
$filter->quiz_id = $quiz->id;
$filter->save();
$out = new stdClass();
$out->name = $filter->name;
$out->id = $filter->id;
$out->saveType = $saveType;
Ajax::output($out);
示例4: elseif
$res = Issue::bulkUpdate();
$tpl->assign('bulk_update_result', $res);
} elseif ($cat == 'set_initial_impact') {
$res = Issue::setImpactAnalysis($iss_id);
$tpl->assign('set_initial_impact_result', $res);
} elseif ($cat == 'add_requirement') {
$res = Impact_Analysis::insert($iss_id);
$tpl->assign('add_requirement_result', $res);
} elseif ($cat == 'set_impact_requirement') {
$res = Impact_Analysis::update($isr_id);
$tpl->assign('set_impact_requirement_result', $res);
} elseif ($cat == 'delete_requirement') {
$res = Impact_Analysis::remove();
$tpl->assign('requirement_delete_result', $res);
} elseif ($cat == 'save_filter') {
$res = Filter::save();
$tpl->assign('save_filter_result', $res);
} elseif ($cat == 'delete_filter') {
$res = Filter::remove();
$tpl->assign('delete_filter_result', $res);
} elseif ($cat == 'remove_support_email') {
$res = Support::removeAssociation();
$tpl->assign('remove_association_result', $res);
} elseif ($cat == 'delete_attachment') {
$res = Attachment::remove($id);
$tpl->assign('remove_attachment_result', $res);
} elseif ($cat == 'delete_file') {
$res = Attachment::removeIndividualFile($id);
$tpl->assign('remove_file_result', $res);
} elseif ($cat == 'remove_checkin') {
$res = SCM::remove($items);
示例5: create
/** static functions **/
function create($vars, &$errors)
{
return Filter::save(0, $vars, $errors);
}
示例6: addFilter
/**
* Add new filter to filter group
*
* @param Filter $filter
*/
public function addFilter(Filter $filter)
{
$filter->filterGroup->set($this);
$filter->save();
}
示例7: executeSaveFilter
/**
* Save a created filter
* @param sfWebRequest $request
* @return <type>
*/
public function executeSaveFilter(sfWebRequest $request) {
$sender_id = $request->getPostParameter('filter_sender') == '' ? -1 : $request->getPostParameter('filter_sender');
$currentStation_id = $request->getPostParameter('filter_currentstation') == '' ? -1 : $request->getPostParameter('filter_currentstation');
$mailingList = $request->getPostParameter('filter_mailinglist') == '' ? -1 : $request->getPostParameter('filter_mailinglist');
$documentTemplate = $request->getPostParameter('filter_documenttemplate') == '' ? -1 : $request->getPostParameter('filter_documenttemplate');
$filter = new Filter();
$filter->setFiltername($request->getPostParameter('filter_hiddenname',''));
$filter->setName($request->getPostParameter('filter_name',''));
$filter->setSenderId($sender_id);
$filter->setDaysfrom($request->getPostParameter('filter_daysinprogress_from',''));
$filter->setDaysto($request->getPostParameter('filter_daysinprogress_to',''));
$filter->setSendetfrom($request->getPostParameter('filter_sendet_from',''));
$filter->setSendetto($request->getPostParameter('filter_sendet_to',''));
$filter->setWorkflowprocessuserId($currentStation_id);
$filter->setMailinglistversionId($mailingList);
$filter->setDocumenttemplateversionId($documentTemplate);
$filter->save();
$filterId = $filter->getId();
// save the field grid
if($request->hasParameter('field')) {
$fields = $request->getParameter('field');
$operators = $request->getParameter('operator');
$values = $request->getParameter('value');
foreach($fields as $key => $field) {
$operator = $operators[$key];
$value = $values[$key];
if($field != '' AND $operator != '' AND $value != '') {
$filterField = new FilterField();
$filterField->setFilterId($filterId);
$filterField->setFieldId($field);
$filterField->setOperator($operator);
$filterField->setValue($value);
$filterField->save();
}
}
}
$this->renderText('{success:true}');
return sfView::NONE;
}
示例8: create
public function create()
{
$details = Input::all();
$validator = Validator::make(array('question' => $details['question'], 'opta' => $details['opta'], 'optb' => $details['optb'], 'optc' => $details['optc'], 'optd' => $details["optd"]), array('question' => 'required|min:4', 'opta' => 'required|min:4', 'optb' => 'required|min:4|', 'optc' => 'required|min:4', 'optd' => 'required|min:4'));
if ($validator->fails() || $details['opta'] == $details['optb'] || $details['opta'] == $details['optc'] || $details['opta'] == $details['optd'] || $details['optb'] == $details['optc'] || $details['optb'] == $details['optd'] || $details['optc'] == $details['optd']) {
return View::make('question_create')->with(array('msg' => "Check your form.Pls Note that the length of the text fields should be > 4", 'title' => 'Post a Question', 'head' => 'Post your question !!!'));
} else {
$question = new Question();
$question->question = $details['question'];
$question->opta = $details['opta'];
$question->optb = $details['optb'];
$question->optc = $details['optc'];
$question->optd = $details['optd'];
$question->answer = $details['answer'];
$question->difficulty = $details['difficulty'];
$question->category = $details['category'];
$question->posted_by = Auth::user()->id;
$question->save();
$filter = new Filter();
$filter->qid = DB::table('questions')->orderBy('qid', 'desc')->where('posted_by', Auth::user()->id)->take(1)->pluck('qid');
$filter->uid = Auth::user()->id;
$filter->save();
return Redirect::to('/home');
}
}
示例9: getZkillboard
/**
* Import zKillboard kills for the selected systems and alliances.
*/
public function getZkillboard($systems = '')
{
// If this is the initial call to the function, retrieve the list of systems from the DB.
if ($systems == '') {
$systems_object = Setting::where('key', 'systems')->firstOrFail();
$systems = $systems_object->value;
}
// Convert the comma-seperated string into an array.
$systems_array = explode(',', $systems);
// If there are more systems in the list than we want to pull at once, chop off the first X and call this function again.
while (count($systems_array) > $this->api_system_limit) {
$this->getZkillboard(implode(',', array_splice($systems_array, 0, $this->api_system_limit)));
}
// Retrieve the selected alliances from the database.
$alliances = Setting::where('key', 'alliances')->firstOrFail();
// Build the API URL.
$url = 'https://zkillboard.com/api/xml/losses/no-attackers/' . 'allianceID/' . preg_replace('/\\s+/', '', $alliances->value) . '/' . 'solarSystemID/' . preg_replace('/\\s+/', '', $systems) . '/';
// Send the request.
$response = Request::get($url)->addHeader('Accept-Encoding', 'gzip')->addHeader('User-Agent', 'Eve Traders Handbook')->send();
if (isset($response->body) && strlen($response->body) > 0) {
$body = simplexml_load_string(gzdecode($response->body));
$insert_count = 0;
// Parse the response, inserting the losses into the database.
foreach ($body->result->rowset->row as $row) {
// First check whether this kill has not already been recorded.
$kill = Kill::find($row['killID']);
if (!isset($kill->killID)) {
// Create and save the new kill record.
$kill = new Kill();
$kill->killID = $row['killID'];
$kill->solarSystemID = $row['solarSystemID'];
$kill->characterID = $row->victim['characterID'];
$kill->characterName = $row->victim['characterName'];
$kill->allianceID = $row->victim['allianceID'];
$kill->corporationID = $row->victim['corporationID'];
$kill->shipTypeID = $row->victim['shipTypeID'];
$kill->killTime = $row['killTime'];
$kill->save();
$insert_count++;
// Insert the alliance information into the database unless it already exists.
$alliance = Alliance::find($kill->allianceID);
if (!isset($alliance->id)) {
$alliance = new Alliance();
$alliance->id = $kill->allianceID;
$alliance->allianceName = $row->victim['allianceName'];
$alliance->save();
}
// Insert the corporation information into the database unless it already exists.
$corporation = Corporation::find($kill->corporationID);
if (!isset($corporation->id)) {
$corporation = new Corporation();
$corporation->id = $kill->corporationID;
$corporation->corporationName = $row->victim['corporationName'];
$corporation->save();
}
// Insert the ship type that was lost into the database unless it already exists.
$ship = Ship::find($kill->shipTypeID);
$type = Type::find($kill->shipTypeID);
if (!isset($ship->id)) {
$ship = new Ship();
$ship->id = $kill->shipTypeID;
$ship->shipName = $type->typeName;
$ship->save();
}
// Insert the ship loss into the items database as well.
if (stristr($ship->shipName, 'Capsule') === FALSE) {
$item = new Item();
$item->killID = $row['killID'];
$item->typeID = $kill->shipTypeID;
$item->typeName = $type->typeName;
$item->categoryName = $type->group->category['categoryName'];
$item->metaGroupName = isset($type->metaType->metaGroup['metaGroupName']) ? $type->metaType->metaGroup['metaGroupName'] : '';
$item->allowManufacture = 1;
$item->qty = 1;
$item->save();
}
// Add the category to the list of filters available on the site.
$filter = Filter::find($type->group->category['categoryID']);
if (!isset($filter->categoryID)) {
$filter = new Filter();
$filter->categoryID = $type->group->category['categoryID'];
$filter->categoryName = $type->group->category['categoryName'];
$filter->iconID = $type->group->category['iconID'];
$filter->save();
}
// Loop through the items lost in the kill. Insert each one into the items table.
if (isset($row->rowset->row)) {
foreach ($row->rowset->row as $loss) {
$typeID = (int) $loss['typeID'];
$item = Item::where('typeID', '=', $typeID)->first();
// If this item already exists in the items table, we don't need to re-query all the additional
// information, we can just copy it from an existing row.
if (isset($item)) {
// This type has already been seen. Duplicate the record and save the new instance.
$clone = new Item();
$clone = $item->replicate();
// Update the right killID and quantity, and unset the primary key and date columns.
//.........这里部分代码省略.........
示例10: executeCreateOkFilter
public function executeCreateOkFilter(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod('post'));
// On récupère les informations dont on a besoin dans le formulaire
$params = array('mode' => 'create', 'filter_id' => $request->getPostParameter('id'), 'filter_name' => $request->getPostParameter('form[name]'), 'filter_description' => $request->getPostParameter('form[description]'), 'private_blacklist_content' => $request->getPostParameter('form[PBlist]'), 'globale_blacklist_content' => $request->getPostParameter('form[GBlist]'), 'private_whitelist_content' => $request->getPostParameter('form[PWlist]'), 'globale_whitelist_content' => $request->getPostParameter('form[GWlist]'));
// Si le champ 'name' est vide, on arrête le traitement
if ($params['filter_name'] == null) {
//return $params;
}
// création du filtre s'il n'existe pas
if ($params['filter_id'] == null) {
$this->menu = $this->getMenu('createFilter');
// On créé un nouveau filtre
$filter = new Filter();
$filter->name = $params['filter_name'];
$filter->description = $params['filter_description'];
$filter->save();
// On récupère son ID
$params['filter_id'] = $filter->id;
// Lien avec liste globales white
$lfwg = new ListsFilter();
$lfwg->filter_id = $params['filter_id'];
$lfwg->list_id = 1;
$lfwg->ordre = 0;
$lfwg->save();
// Lien avec liste global black
$lfbg = new ListsFilter();
$lfbg->filter_id = $params['filter_id'];
$lfbg->list_id = 2;
$lfbg->ordre = 1;
$lfbg->save();
// Création liste SI White du filtre
$lists = new Lists();
$lists->name = "PW" . $params['filter_id'];
$lists->type = "W";
$lists->origin = "SI";
$lists->static = 0;
$lists->save();
$lfwp = new ListsFilter();
$lfwp->filter_id = $params['filter_id'];
$lfwp->list_id = $lists->id;
$lfwp->ordre = 2;
$lfwp->save();
// Création liste SI Black du filtre
$lists = new Lists();
$lists->name = "PB" . $params['filter_id'];
$lists->type = "B";
$lists->origin = "SI";
$lists->static = 0;
$lists->save();
$lfbp = new ListsFilter();
$lfbp->filter_id = $params['filter_id'];
$lfbp->list_id = $lists->id;
$lfbp->ordre = 3;
$lfbp->save();
} else {
$this->menu = $this->getMenu('index');
$sql = "UPDATE filter SET name = '{$params['filter_name']}', description = '{$params['filter_description']}' WHERE id = '{$params['filter_id']}';";
$dq = new Doctrine_Query();
$conn = $dq->getConnection();
$conn->execute($sql);
}
// On remet à jour les listes SI
$private_blacklist_content_details = explode("\n", $params['private_blacklist_content']);
$globale_blacklist_content_details = explode("\n", $params['globale_blacklist_content']);
$private_whitelist_content_details = explode("\n", $params['private_whitelist_content']);
$globale_whitelist_content_details = explode("\n", $params['globale_whitelist_content']);
// Mise à jour White liste Globale
$listGlobale_whitelist = Doctrine_Query::create()->delete()->from('ListsDetail')->where('lists_id = ?', 1)->execute();
for ($i = 0; $i < count($globale_whitelist_content_details); $i++) {
if (trim($globale_whitelist_content_details[$i]) != "") {
$insert = new ListsDetail();
$insert->domain = trim($globale_whitelist_content_details[$i]);
$insert->lists_id = 1;
$insert->save();
}
}
// Mise à jour Black liste Globale
$listGlobale_blacklist = Doctrine_Query::create()->delete()->from('ListsDetail')->where('lists_id = ?', 2)->execute();
for ($i = 0; $i < count($globale_blacklist_content_details); $i++) {
if (trim($globale_blacklist_content_details[$i]) != "") {
$insert = new ListsDetail();
$insert->domain = trim($globale_blacklist_content_details[$i]);
$insert->lists_id = 2;
$insert->save();
}
}
// Mise à jour White liste Locale
// Recherche de l'id de la liste
$lists_query = Doctrine_Query::create()->select('id')->from('Lists')->where('name = ?', 'PW' . $params['filter_id']);
$lists_res = $lists_query->fetchOne();
$id_PW = $lists_res['id'];
// Suppression des détails
$listLocale_whitelist = Doctrine_Query::create()->delete()->from('ListsDetail')->where('lists_id = ?', $id_PW)->execute();
for ($i = 0; $i < count($private_whitelist_content_details); $i++) {
if (trim($private_whitelist_content_details[$i]) != "") {
$insert = new ListsDetail();
$insert->domain = trim($private_whitelist_content_details[$i]);
$insert->lists_id = $id_PW;
$insert->save();
//.........这里部分代码省略.........
示例11: executeCreateOkFilter
public function executeCreateOkFilter(sfWebRequest $request)
{
$this->menu = $this->getMenu('index');
$this->forward404Unless($request->isMethod('post'));
// On récupère les informations dont on a besoin dans le formulaire
$params = array('mode' => 'create', 'filter_id' => $request->getPostParameter('id'), 'filter_name' => $request->getPostParameter('form[name]'), 'filter_description' => $request->getPostParameter('form[description]'), 'private_blacklist_content' => $request->getPostParameter('form[PBlist]'), 'globale_blacklist_content' => $request->getPostParameter('form[GBlist]'), 'private_whitelist_content' => $request->getPostParameter('form[PWlist]'), 'globale_whitelist_content' => $request->getPostParameter('form[GWlist]'));
// Si le champ 'name' est vide, on arrête le traitement
if ($params['filter_name'] == null) {
//return $params;
}
if ($params['filter_id'] == null) {
// On créé un nouveau filtre
$filter = new Filter();
$filter->name = $params['filter_name'];
$filter->description = $params['filter_description'];
$filter->save();
// On récupère son ID
$params['filter_id'] = $filter->id;
} else {
$params['mode'] = 'update';
$sql = <<<SQL
\t\t\t\tSELECT ld.id, ld.lists_id
\t\t\t\tFROM lists_detail ld
\t\t\t\t\tLEFT JOIN lists li ON ld.lists_id = li.id
\t\t\t\t\tLEFT JOIN lists_filter lf ON li.id = lf.list_id
\t\t\t\tWHERE lf.filter_id = '{$params['filter_id']}'
\t\t\t\t\tAND li.origin = 'SI'
\t\t\t\tORDER BY ld.lists_id
SQL;
$dq = new Doctrine_Query();
$conn = $dq->getConnection();
$lists = $conn->fetchAll($sql);
foreach ($lists as $list) {
$sql = <<<SQL
\t\t\t\t\tDELETE FROM lists_detail WHERE id = '{$list['id']}';
SQL;
$dq = new Doctrine_Query();
$conn = $dq->getConnection();
$conn->execute($sql);
if ($list['lists_id'] != $ancVal) {
$ancVal = $list['lists_id'];
$sql = <<<SQL
\t\t\t\t\t\tDELETE FROM lists WHERE id = '{$ancVal}';
SQL;
$dq = new Doctrine_Query();
$conn = $dq->getConnection();
$conn->execute($sql);
}
}
$sql = "UPDATE filter SET name = '{$params['filter_name']}', description = '{$params['filter_description']}' WHERE id = '{$params['filter_id']}';";
$dq = new Doctrine_Query();
$conn = $dq->getConnection();
$conn->execute($sql);
$deleteAllListFilter = Doctrine_Query::create()->delete()->from('ListsFilter')->where('filter_id = ?', $params['filter_id'])->execute();
}
// On remet à jour les listes globales
$private_blacklist_content_details = explode("\n", $params['private_blacklist_content']);
$globale_blacklist_content_details = explode("\n", $params['globale_blacklist_content']);
$private_whitelist_content_details = explode("\n", $params['private_whitelist_content']);
$globale_whitelist_content_details = explode("\n", $params['globale_whitelist_content']);
$listGlobale_whitelist = Doctrine_Query::create()->delete()->from('ListsDetail')->where('lists_id = ?', 0)->execute();
for ($i = 0; $i < count($globale_whitelist_content_details); $i++) {
if ($globale_whitelist_content_details[$i] != null) {
$insert = new ListsDetail();
$insert->domain = $globale_whitelist_content_details[$i];
$insert->lists_id = 0;
$insert->save();
}
}
$listGlobale_blacklist = Doctrine_Query::create()->delete()->from('ListsDetail')->where('lists_id = ?', 1)->execute();
for ($i = 0; $i < count($globale_blacklist_content_details); $i++) {
if ($globale_blacklist_content_details[$i] != null) {
$insert = new ListsDetail();
$insert->domain = $globale_blacklist_content_details[$i];
$insert->lists_id = 1;
$insert->save();
}
}
// On les attachent au filtre que l'on a créé
$attach_global_whitelist = new ListsFilter();
$attach_global_whitelist->list_id = 0;
$attach_global_whitelist->filter_id = $params['filter_id'];
$attach_global_whitelist->ordre = 0;
$attach_global_whitelist->save();
$attach_global_blacklist = new ListsFilter();
$attach_global_blacklist->list_id = 1;
$attach_global_blacklist->filter_id = $params['filter_id'];
$attach_global_blacklist->ordre = 1;
$attach_global_blacklist->save();
// On créé une nouvelle liste (whitelist)
if ($params['private_whitelist_content'] != null) {
$whitelist = new Lists();
$whitelist->name = 'PW' . $params['filter_id'];
$whitelist->type = 'W';
$whitelist->origin = 'SI';
$whitelist->static = '1';
$whitelist->save();
$id = $whitelist->id;
for ($i = 0; $i < count($private_whitelist_content_details); $i++) {
if ($private_whitelist_content_details[$i] != null) {
//.........这里部分代码省略.........