本文整理汇总了PHP中Section::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Section::save方法的具体用法?PHP Section::save怎么用?PHP Section::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Section
的用法示例。
在下文中一共展示了Section::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addSectionAction
public function addSectionAction()
{
if ($this->request->isPost() == true) {
$ans = [];
$sectionName = $this->request->getPost("name");
$existSection = Section::find(array("conditions" => "name=?1", "bind" => array(1 => $sectionName)));
if (count($existSection) == 0) {
$section = new Section();
$section->name = $sectionName;
if ($section->save()) {
$ans['id'] = $section->id;
echo json_encode($ans);
} else {
foreach ($section->getMessages() as $message) {
throw new BaseException($message, 100);
}
}
} else {
throw new BaseException('栏目已存在', 101);
}
/* try {
} catch (BaseException $e) {
}*/
}
}
示例2: validate
protected function validate()
{
$required = array("class_level" => "Class", "section" => "Section", "code" => "Code");
global $user;
if ($user->checkAdmin() == true) {
if (isset($_POST)) {
foreach ($required as $key => $value) {
if (!isset($_POST[$key]) || $_POST[$key] == '' || $_POST[$key] == 'select') {
echo $value . ' is Required<br/>';
return;
}
}
echo 'Saving...';
global $objPDO;
require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/section_class.php';
$section = new Section($objPDO);
$section->setClass($_POST['class_level']);
$section->setSection($_POST['section']);
$section->setCode($_POST['code']);
$section->save();
echo '<meta http-equiv="Refresh" content="0;url=http://localhost/cloud/miscellaneous"/>';
}
} else {
header('Location:http://localhost/cloud');
}
}
示例3: doSave
/**
* Performs the work of inserting or updating the row in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave(PropelPDO $con)
{
$affectedRows = 0;
// initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aSection !== null) {
if ($this->aSection->isModified() || $this->aSection->isNew()) {
$affectedRows += $this->aSection->save($con);
}
$this->setSection($this->aSection);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例4: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Section();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Section'])) {
$model->attributes = $_POST['Section'];
if ($model->save()) {
$orgs = isset($_POST['Section']['Organization']) ? $_POST['Section']['Organization'] : array();
$model->saveRelationOrganizations($orgs, $model->id);
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例5: add
public static function add($name, $description = "", $grantAdmin = true)
{
$sectionManager = new Section();
if ($sectionManager->rowCount(array('label' => $name)) == 0) {
$sectionManager->setLabel($name);
$sectionManager->setDescription($description);
$sectionManager->save();
if ($grantAdmin) {
$right = new Right();
$right = $right->load(array('section' => $sectionManager->getLabel(), 'rank' => 1));
$right = !$right ? new Right() : $right;
$right->setSection($sectionManager->getId());
$right->setCreate(1);
$right->setRead(1);
$right->setUpdate(1);
$right->setDelete(1);
$right->setRank(1);
$right->save();
}
}
}
示例6: while
function _saveSections()
{
require_once 'AMP/Content/Section.inc.php';
$section_count = 1;
$form =& $this->get_form();
while (isset($this->_request_vars[$this->_get_section_fieldname($section_count)]) && $this->_request_vars[$this->_get_section_fieldname($section_count)]) {
$name = $this->_request_vars[$this->_get_section_fieldname($section_count)];
$text = $this->_request_vars[$this->_get_section_fieldname($section_count, 'text')];
$section = new Section(AMP_Registry::getDbcon());
$section->setName($name);
$section->setBlurb($text);
$section->setParent();
$section->setListType();
if (!($result = $section->save())) {
++$section_count;
continue;
}
$section->publish();
$section->reorder($section_count);
$form->setValues(array($this->_get_section_fieldname($section_count) => '', $this->_get_section_fieldname($section_count, 'text') => ''));
$this->message(sprintf(AMP_TEXT_DATA_SAVE_SUCCESS, $section->getName()));
++$section_count;
}
}
示例7: buildDataXML
public function buildDataXML($data)
{
$section_xml = $this->document->createElement('section');
$section_xml->setAttribute('handle', $this->section->handle);
$filter = $filter_value = $where = $joins = NULL;
$current_page = isset($_REQUEST['pg']) && is_numeric($_REQUEST['pg']) ? max(1, intval($_REQUEST['pg'])) : 1;
$current_filter = $filter ? "&filter={$field_handle}:{$filter_value}" : '';
if (isset($_REQUEST['sort']) && is_string($_REQUEST['sort'])) {
$sort = $_REQUEST['sort'];
$order = $_REQUEST['order'] ? strtolower($_REQUEST['order']) : 'asc';
if ($this->section->{'publish-order-handle'} != $sort || $this->section->{'publish-order-direction'} != $order) {
$this->section->{'publish-order-handle'} = $sort;
$this->section->{'publish-order-direction'} = $order;
$errors = new MessageStack();
Section::save($this->section, $errors);
redirect($url . $current_filter);
}
} elseif (isset($_REQUEST['unsort'])) {
$section->{'publish-order-handle'} = null;
$section->{'publish-order-direction'} = null;
$errors = new MessageStack();
Section::save($section, $errors);
redirect($URL);
}
$fields_xml = $this->document->createElement('fields');
foreach ($this->section->fields as $column) {
if ($column->{'show-column'} == 'yes') {
$field = $this->document->createElement('field', $column->name);
$field->setAttribute('handle', $column->{'element-name'});
$fields_xml->appendChild($field);
}
}
$section_xml->appendChild($fields_xml);
try {
$entry_count = Symphony::Database()->query("SELECT COUNT(id) as `count` FROM `tbl_entries` WHERE `section` = '%s'", array($section->handle))->current()->count;
} catch (DatabaseException $ex) {
}
$pagination_xml = $this->document->createElement('pagination');
$pagination_xml->appendChild($this->document->createElement('total-entries', $entry_count));
$pagination_xml->appendChild($this->document->createElement('per-page', Symphony::Configuration()->core()->symphony->{'pagination-maximum-rows'}));
$pagination_xml->appendChild($this->document->createElement('total-pages', ceil($entry_count / Symphony::Configuration()->core()->symphony->{'pagination-maximum-rows'})));
$pagination_xml->appendChild($this->document->createElement('current-page', $current_page));
$section_xml->appendChild($pagination_xml);
// Simplified/messy entry fetching
$entries = Symphony::Database()->query("SELECT * FROM `tbl_entries` WHERE `section` = '%s' ORDER BY `id` ASC", array($this->section->handle), 'EntryResult');
$entries_xml = $this->document->createElement('entries');
foreach ($entries as $entry) {
$entry_xml = $this->document->createElement('entry');
$entry_xml->setAttribute('id', $entry->id);
$fields_xml = $this->document->createElement('fields');
foreach ($this->section->fields as $column) {
if ($column->{'show-column'} != 'yes') {
continue;
}
$field_handle = $column->{'element-name'};
$fields_xml->appendChild($this->document->createElement($field_handle, $entry->data()->{$field_handle}->value));
}
$entry_xml->appendChild($fields_xml);
$entries_xml->appendChild($entry_xml);
}
$section_xml->appendChild($entries_xml);
$data->appendChild($section_xml);
}
示例8: editaction
/**
* edit section in system (the action page)
*
* @return void
*/
public function editaction()
{
$s = new Section($this->input->post('id'));
$s->name = $this->input->post('name');
$s->view = $this->input->post('view');
$s->save();
redirect('section_editor');
}
示例9: Section
function _checkNewSection($data, $fieldname)
{
if (!(isset($data['new_section_name']) && $data['new_section_name'])) {
if (!isset($data[$fieldname])) {
return false;
}
return $data[$fieldname];
}
require_once 'AMP/Content/Section.inc.php';
$section = new Section(AMP_Registry::getDbcon());
$section->setDefaults();
$section->setName($data['new_section_name']);
$section->setParent($data['new_section_parent']);
if (!($result = $section->save())) {
return $data[$fieldname];
}
$section->publish();
$flash =& AMP_System_Flash::instance();
$flash->add_message(sprintf(AMP_TEXT_DATA_SAVE_SUCCESS, $section->getName()));
return $section->id;
}
示例10: install
function install()
{
$CI =& get_instance();
$CI->load->dbforge();
// loading objects;
$CI->config->load('objects');
$tables = $CI->config->item('objects');
$tables_keys = array_keys($tables);
foreach ($tables_keys as $item) {
$CI->dbforge->add_field($tables[$item]);
$CI->dbforge->create_table($item);
$CI->db->query("ALTER TABLE `" . $item . "` ADD COLUMN `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (`id`)");
}
$CI->load->library('datamapper');
//adding the default section
$index = new Section();
$index->parent_section = 0;
$index->sort = 0;
$index->save();
$page_body = new Content();
$page_body->sub_section = intval(TRUE);
$page_body->cell = 0;
$page_body->sort = 0;
$page_body->parent_section = $index->id;
$page_body->info = 'PAGE_BODY_LOCKED';
$page_body->save();
$default_layout = new Content();
$default_layout->path = 'default.php';
$default_layout->parent_content = 1;
$default_layout->parent_section = 1;
$default_layout->subsection = 0;
$default_layout->cell = 0;
$default_layout->sort = 0;
$default_layout->save();
}
示例11: Rank
$configuration->put('COOKIE_LIFETIME', '7');
$configuration->put('VOCAL_ENTITY_NAME', 'YANA');
$configuration->put('PROGRAM_VERSION', '3.0.6');
$configuration->put('HOME_PAGE', 'index.php');
$configuration->put('VOCAL_SENSITIVITY', '0.0');
//Création du rang admin
$rank = new Rank();
$rank->setLabel('admin');
$rank->save();
//Déclaration des sections du programme
$sections = array('event', 'vocal', 'user', 'plugin', 'configuration', 'admin');
//Création des sections déclarées et attribution de tous les droits sur toutes ces sections pour l'admin
foreach ($sections as $sectionName) {
$s = new Section();
$s->setLabel($sectionName);
$s->save();
$r = new Right();
$r->setSection($s->getId());
$r->setRead('1');
$r->setDelete('1');
$r->setCreate('1');
$r->setUpdate('1');
$r->setRank($rank->getId());
$r->save();
}
$personalities = array('John Travolta', 'Jeff Buckley', 'Tom Cruise', 'John Lennon', 'Emmet Brown', 'Geo trouvetou', 'Luke Skywalker', 'Mac Gyver', 'Marty McFly');
$im = $personalities[rand(0, count($personalities) - 1)];
list($fn, $n) = explode(' ', $im);
//Creation du premier compte et assignation en admin
$user->setMail($_POST['email']);
$user->setPassword($_POST['password']);
示例12: make
public function make($section_title, $content, $title, $url, $nsfw, $nsfl, Section $section)
{
$section_title = strtolower($section_title);
$block = new SuccessBlock();
$block->data->section_title = $section_title;
$block->data->item_title = Utility::prettyUrl($title);
if ($block->success) {
if (Auth::user()->points < 1) {
$block->success = false;
$block->errors[] = 'You need at least one point to post';
}
}
if ($block->success) {
if (!$this->canPost()) {
$block->success = false;
$block->errors[] = 'can only post ' . Utility::availablePosts() . ' per day';
}
}
if ($block->success) {
$data = $this->prepareData(['data' => $content, 'title' => $title, 'url' => $url, 'user_id' => Auth::user()->id, 'nsfw' => $nsfw, 'nsfl' => $nsfl]);
$rules = $this->generateRules($data);
$validate = Validator::make($data, $this->generateRules($data));
if ($validate->fails()) {
$block->success = false;
foreach ($validate->messages()->all() as $v) {
$block->errors[] = $v;
}
}
}
if ($block->success) {
//check if .gif & gfycat it
$data['url'] = $this->gfycatUrl($data['url']);
if (!$section->exists($section_title)) {
$ssect = new Section(['title' => $section_title]);
if (!$ssect->save()) {
$block->success = false;
$block->errors[] = 'unable to create new spreadit';
$block->data->section_title = str_replace(' ', '_', $block->data->section_title);
}
}
}
if ($block->success) {
$section = $section->sectionFromSections($section->getByTitle(Utility::splitByTitle($section_title)));
if ($section->id < 1) {
$block->success = false;
$block->errors[] = 'can only post to a real section(you probably tried to post to /s/all)';
}
}
if ($block->success) {
$data['section_id'] = $section->id;
$item = new Post($data);
$item->save();
if (isset($rules['url'])) {
if (Utility::urlExists($data['url'])) {
Utility::thumbnailScript($item->id, $data['url']);
}
}
//add a point for adding posts
if (Auth::user()->anonymous == 0) {
Auth::user()->increment('points');
}
$block->data->item_id = $item->id;
} else {
$block->data->item_id = null;
}
return $block;
}
示例13: Sensor
Le code contenu dans cette page ne sera éxecuté qu'à l'activation du plugin
Vous pouvez donc l'utiliser pour créer des tables SQLite, des dossiers, ou executer une action
qui ne doit se lancer qu'à l'installation ex :
*/
require_once 'Sensor.class.php';
$table = new Sensor();
$table->create();
require_once 'SensorType.class.php';
$table2 = new SensorType();
$table2->create();
$s1 = new Section();
$s1->setLabel('sensor');
$s1->save();
$s2 = new Section();
$s2->setLabel('sensortypes');
$s2->save();
$r1 = new Right();
$r1->setSection($s1->getId());
$r1->setRead('1');
$r1->setDelete('1');
$r1->setCreate('1');
$r1->setUpdate('1');
$r1->setRank('1');
$r1->save();
$r2 = new Right();
$r2->setSection($s2->getId());
$r2->setRead('1');
$r2->setDelete('1');
$r2->setCreate('1');
$r2->setUpdate('1');
$r2->setRank('1');
示例14: __save
private function __save(array $essentials = null, array $fields = null, array $layout = null, Section $section = null)
{
if (is_null($section)) {
$section = new Section();
$section->path = SECTIONS;
}
$this->section = $section;
$this->errors = new MessageStack();
$old_handle = false;
if (is_array($essentials)) {
if ($essentials['name'] !== $this->section->name and $this->section->name != '') {
$old_handle = $this->section->handle;
}
$this->section->name = $essentials['name'];
$this->section->{'navigation-group'} = $essentials['navigation-group'];
$this->section->{'hidden-from-publish-menu'} = isset($essentials['hidden-from-publish-menu']) && $essentials['hidden-from-publish-menu'] == 'yes' ? 'yes' : 'no';
}
// Resave fields:
if (!is_null($fields)) {
$this->section->removeAllFields();
if (is_array($fields) and !empty($fields)) {
foreach ($fields as $field) {
$this->section->appendFieldByType($field['type'], $field);
}
}
}
// Resave layout:
if (!is_null($layout)) {
foreach ($layout as &$column) {
$column = (object) $column;
if (is_array($column->fieldsets)) {
foreach ($column->fieldsets as &$fieldset) {
$fieldset = (object) $fieldset;
}
}
}
$this->section->layout = $layout;
}
try {
$callback = Administration::instance()->getPageCallback();
$current_page = $callback['pageroot'] . $callback['context'][0] . '/';
###
# Delegate: SectionPreSave
Extension::notify('SectionPreSave', $current_page, array('section' => &$this->section, 'errors' => &$this->errors));
Section::save($this->section, $this->errors);
###
# Delegate: SectionPostSave
Extension::notify('SectionPostSave', $current_page, array('section' => &$this->section, 'errors' => &$this->errors));
// Rename section:
if ($old_handle !== false) {
Section::rename($this->section, $old_handle);
###
# Delegate: SectionPostRename
Extension::notify('SectionPostRename', $current_page, array('section' => &$this->section, 'old-handle' => $old_handle, 'errors' => &$this->errors));
}
Section::synchronise($this->section);
return true;
} catch (SectionException $e) {
switch ($e->getCode()) {
case Section::ERROR_MISSING_OR_INVALID_FIELDS:
$this->alerts()->append(__('Could not save the layout, there are errors in your field configuration. <a class="more">More information.</a>'), AlertStack::ERROR, $this->errors);
break;
case Section::ERROR_FAILED_TO_WRITE:
$this->alerts()->append($e->getMessage(), AlertStack::ERROR);
break;
}
} catch (Exception $e) {
$this->alerts()->append(__('An unknown error has occurred. <a class="more">Show trace information.</a>'), AlertStack::ERROR, $e);
}
return false;
}
示例15: showEditSectionRes
function showEditSectionRes()
{
$displaySysAdmin = new DisplaySysAdmin();
$survey = new Survey($_SESSION['SUID']);
$seid = getFromSessionParams('seid');
$content = "";
if ($seid != '') {
//edit
$section = $survey->getSection($seid);
$_SESSION['SEID'] = $seid;
$content = $displaySysAdmin->displaySuccess(Language::messageSectionChanged(loadvar(SETTING_NAME)));
} else {
//add section!
if (loadvar(SETTING_NAME) != "") {
$section = new Section();
$section->setSuid($_SESSION['SUID']);
$content = $displaySysAdmin->displaySuccess(Language::messageSectionAdded(loadvar(SETTING_NAME)));
}
}
$checker = new Checker($_SESSION['SUID']);
if ($seid == '') {
$checks = $checker->checkName(loadvar(SETTING_NAME));
if (sizeof($checks) > 0) {
$content = implode("<br/>", $checks);
return $this->showAddSection($content);
}
}
//ADD ALL SORTS OF CHECKS!!
if ($seid != '' || loadvar(SETTING_NAME) != "") {
$section->setName(trim(loadvar(SETTING_NAME)));
$section->setDescription(loadvar(SETTING_DESCRIPTION));
$section->setHidden(loadvar(SETTING_HIDDEN));
$section->setHeader(loadvarAllowHTML(SETTING_SECTION_HEADER));
$section->setFooter(loadvarAllowHTML(SETTING_SECTION_FOOTER));
$section->save();
$checks = $checker->checkSection($section);
if (sizeof($checks) > 0) {
$content .= $displaySysAdmin->displayError(implode("<br/>", $checks));
}
}
/* compile */
$compiler = new Compiler($_SESSION['SUID'], getSurveyVersion($survey));
$mess = $compiler->generateSections(array($section));
$mess = $compiler->generateGetFillsSections(array($section));
$mess = $compiler->generateInlineFieldsSections(array($section));
/* update last page */
$_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res"));
if ($seid != '') {
return $displaySysAdmin->showEditSection($_SESSION['SEID'], $content);
} else {
return $displaySysAdmin->showSurvey($content);
}
}