本文整理汇总了PHP中Label::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Label::save方法的具体用法?PHP Label::save怎么用?PHP Label::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Label
的用法示例。
在下文中一共展示了Label::save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateset
function updateset($lid)
{
$clang = Yii::app()->lang;
// Get added and deleted languagesid arrays
if ($_POST['languageids']) {
$postlanguageids = sanitize_languagecodeS($_POST['languageids']);
}
if ($_POST['label_name']) {
$postlabel_name = sanitize_labelname($_POST['label_name']);
}
$newlanidarray = explode(" ", trim($postlanguageids));
$oldlangidsarray = array();
$labelset = Labelsets::model()->findByAttributes(array('lid' => $lid));
$oldlangidsarray = explode(' ', $labelset->languages);
$addlangidsarray = array_diff($newlanidarray, $oldlangidsarray);
$dellangidsarray = array_diff($oldlangidsarray, $newlanidarray);
// If new languages are added, create labels' codes and sortorder for the new languages
$result = Label::model()->findAllByAttributes(array('lid' => $lid), array('order' => 'code, sortorder, assessment_value'));
if ($result) {
foreach ($result as $row) {
$oldcodesarray[$row['code']] = array('sortorder' => $row['sortorder'], 'assessment_value' => $row['assessment_value']);
}
}
if (isset($oldcodesarray) && count($oldcodesarray) > 0) {
foreach ($addlangidsarray as $addedlangid) {
foreach ($oldcodesarray as $oldcode => $olddata) {
$sqlvalues[] = array('lid' => $lid, 'code' => $oldcode, 'sortorder' => $olddata['sortorder'], 'language' => $addedlangid, 'assessment_value' => $olddata['assessment_value']);
}
}
}
if (isset($sqlvalues)) {
foreach ($sqlvalues as $sqlvalue) {
$label = new Label();
foreach ($sqlvalue as $name => $value) {
$label->setAttribute($name, $value);
}
$label->save();
}
}
// If languages are removed, delete labels for these languages
$criteria = new CDbCriteria();
$criteria->addColumnCondition(array('lid' => $lid));
$langcriteria = new CDbCriteria();
foreach ($dellangidsarray as $dellangid) {
$langcriteria->addColumnCondition(array('language' => $dellangid), 'OR');
}
$criteria->mergeWith($langcriteria);
if (!empty($dellangidsarray)) {
$result = Label::model()->deleteAll($criteria);
}
// Update the label set itself
$labelset->label_name = $postlabel_name;
$labelset->languages = $postlanguageids;
$labelset->save();
}
示例2: updateActual
public function updateActual($aData)
{
if (isset($aData['id'])) {
$this->id = $aData['id'];
$this->edited = new Doctrine_Expression('NOW()');
} else {
$this->created = new Doctrine_Expression('NOW()');
$this->edited = new Doctrine_Expression('NOW()');
}
$aTags = Tag::checkTags(Tag::makeTags($aData['tags']));
$this->title = $aData['title'];
$this->shortcontent = trim(stripslashes($aData['shortcontent']));
$this->fullcontent = trim(stripslashes($aData['fullcontent']));
$this->tags = $aData['tags'];
$this->active = $aData['active'];
$this->link = Webbers_Normalize::Link($aData['title']);
$this->AktualsTags->delete();
$this->AktualsLabels->delete();
$this->save();
if (sizeof($aTags) > 0) {
foreach ($aTags as $tag) {
$aktualTags = new AktualsTag();
$aktualTags->Aktuals_id = $this->id;
$aktualTags->Tags_id = $tag->id;
$aktualTags->save();
}
}
$labels = array();
if (isset($aData['newlabel']) and $aData['newlabel'] != '') {
$newLabel = Webbers_Normalize::Name($aData['newlabel']);
$label = Label::getLabel($newLabel);
if ($label != false) {
$labelID = $label->id;
} else {
$label = new Label();
$label->Gname = $newLabel;
$label->save();
$labelID = $label->getIncremented();
}
$labels = array($labelID);
}
if (isset($aData['labels']) and sizeof($aData['labels']) > 0) {
$labels = array_unique(array_merge($aData['labels'], $labels));
foreach ($labels as $lab) {
$al = new AktualsLabel();
$al->Labels_id = $lab;
$al->Aktuals_id = $this->id;
$al->save();
}
}
return $this->id;
}
示例3: ajaxSets
public function ajaxSets()
{
$lid = Yii::app()->getRequest()->getPost('lid');
$answers = Yii::app()->getRequest()->getPost('answers');
$code = Yii::app()->getRequest()->getPost('code');
$aAssessmentValues = Yii::app()->getRequest()->getPost('assessmentvalues', array());
//Create new label set
$language = "";
foreach ($answers as $lang => $answer) {
$language .= $lang . " ";
}
$language = trim($language);
if ($lid == 0) {
$lset = new LabelSet();
$lset->label_name = Yii::app()->getRequest()->getPost('laname');
$lset->languages = $language;
$lset->save();
$lid = getLastInsertID($lset->tableName());
} else {
Label::model()->deleteAll('lid = :lid', array(':lid' => $lid));
}
$res = 'ok';
//optimistic
foreach ($answers as $lang => $answer) {
foreach ($answer as $key => $ans) {
$label = new Label();
$label->lid = $lid;
$label->code = $code[$key];
$label->title = $ans;
$label->sortorder = $key;
$label->language = $lang;
$label->assessment_value = isset($aAssessmentValues[$key]) ? $aAssessmentValues[$key] : 0;
if (!$label->save()) {
$res = 'fail';
}
}
}
echo ls_json_encode($res);
}
示例4: createLayersForLU
public function createLayersForLU($lu, $data)
{
$layerType = new LayerType();
$layerTypes = $layerType->listToLU($lu);
foreach ($layerTypes as $lt) {
$layer = new Layer();
$layer->setIdLayerType($lt['idLayerType']);
$layer->setIdAnnotationSet($this->getId());
$layer->setRank(1);
$layer->save();
if ($lt['entry'] == 'lty_target') {
$label = new Label();
$label->setMulti(false);
$label->setIdInstantiationTypeFromEntry('int_normal');
$idLabelType = $layerType->listLabelType((object) ['entry' => 'lty_target'])->asQuery()->getResult()[0]['idLabelType'];
$label->setIdLabelType($idLabelType);
$label->setIdLayer($layer->getId());
$label->setStartChar($data->startChar);
$label->setEndChar($data->endChar);
$label->save();
}
}
}
示例5: modlabelsetanswers
function modlabelsetanswers($lid)
{
//global $labelsoutput;
$clang = Yii::app()->lang;
$ajax = false;
if (isset($_POST['ajax']) && $_POST['ajax'] == "1") {
$ajax = true;
}
if (!isset($_POST['method'])) {
$_POST['method'] = $clang->gT("Save");
}
$sPostData = Yii::app()->getRequest()->getPost('dataToSend');
$sPostData = str_replace("\t", '', $sPostData);
if (get_magic_quotes_gpc()) {
$data = json_decode(stripslashes($sPostData));
} else {
$data = json_decode($sPostData);
}
if ($ajax) {
$lid = insertlabelset();
}
$aErrors = array();
if (count(array_unique($data->{'codelist'})) == count($data->{'codelist'})) {
$query = "DELETE FROM {{labels}} WHERE lid = '{$lid}'";
$result = Yii::app()->db->createCommand($query)->execute();
foreach ($data->{'codelist'} as $index => $codeid) {
$codeObj = $data->{$codeid};
$actualcode = $codeObj->{'code'};
//$codeid = dbQuoteAll($codeid,true);
$assessmentvalue = (int) $codeObj->{'assessmentvalue'};
foreach ($data->{'langs'} as $lang) {
$strTemp = 'text_' . $lang;
$title = $codeObj->{$strTemp};
$sortorder = $index;
$oLabel = new Label();
$oLabel->lid = $lid;
$oLabel->code = $actualcode;
$oLabel->title = $title;
$oLabel->sortorder = $sortorder;
$oLabel->assessment_value = $assessmentvalue;
$oLabel->language = $lang;
if ($oLabel->validate()) {
$result = $oLabel->save();
} else {
$aErrors[] = $oLabel->getErrors();
}
}
}
if (count($aErrors)) {
Yii::app()->session['flashmessage'] = $clang->gT("Not all labels were updated successfully.");
} else {
Yii::app()->session['flashmessage'] = $clang->gT("Labels sucessfully updated");
}
} else {
Yii::app()->setFlashMessage($clang->gT("Can't update labels because you are using duplicated codes"), 'error');
}
if ($ajax) {
die;
}
}
示例6: ajaxSets
public function ajaxSets()
{
$lid = Yii::app()->getRequest()->getPost('lid');
$answers = Yii::app()->getRequest()->getPost('answers');
$code = Yii::app()->getRequest()->getPost('code');
//Create new label set
$language = "";
foreach ($answers as $lang => $answer) {
$language .= $lang . " ";
}
$language = trim($language);
if ($lid == 0) {
$lset = new Labelsets();
$lset->label_name = sanitize_xss_string(Yii::app()->getRequest()->getPost('laname'));
$lset->languages = sanitize_xss_string($language);
$lset->save();
$lid = Yii::app()->db->getCommandBuilder()->getLastInsertID($lset->tableName());
} else {
Label::model()->deleteAll('lid = :lid', array(':lid' => $lid));
}
$res = 'ok';
//optimistic
foreach ($answers as $lang => $answer) {
foreach ($answer as $key => $ans) {
$label = new Label();
$label->lid = $lid;
$label->code = $code[$key];
$label->title = $ans;
$label->sortorder = $key;
$label->language = $lang;
if (!$label->save()) {
$res = 'fail';
}
}
}
echo ls_json_encode($res);
}
示例7: Label
<?php
/**
* ManiaPress: a suite to display your WordPress install directly in Maniaplanet.
*
* @see http://code.google.com/p/maniapress/
* @copyright Copyright (c) 2011-2012 NADEO (http://www.nadeo.com)
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
* @version $Revision$:
* @author $Author$:
* @date $Date$:
*/
get_header('single');
if (have_posts()) {
the_post();
get_template_part('content', 'single');
} else {
$ui = new Label(120 / 1.5);
$ui->setScale(1.5);
$ui->setHalign('center');
$ui->setPosition(0, 40, 0.2);
$ui->enableAutonewline();
$ui->setStyle(Label::TextButtonSmall);
$ui->setText('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.');
$ui->save();
}
get_sidebar('single');
get_footer('single');
示例8: ContactMethod
$methods = $result['items'];
foreach ($methods as $m) {
$o = new ContactMethod();
$o->setName($m);
$o->save();
echo "ContactMethod: {$o->getName()}\n";
}
$result = $mongo->lookups->findOne(array('name' => 'types'));
$types = $result['items'];
foreach ($types as $t) {
$o = new IssueType();
$o->setName($t);
$o->save();
echo "IssueType: {$o->getName()}\n";
}
$result = $mongo->lookups->findOne(array('name' => 'labels'));
$labels = $result['items'];
foreach ($labels as $l) {
$o = new Label();
$o->setName($l);
$o->save();
echo "Label: {$o->getName()}\n";
}
$result = $mongo->categoryGroups->find();
foreach ($result as $r) {
$o = new CategoryGroup();
$o->setName($r['name']);
$o->setOrdering($r['order']);
$o->save();
echo "CategoryGroup: {$o->getName()}\n";
}