本文整理汇总了PHP中Element::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::model方法的具体用法?PHP Element::model怎么用?PHP Element::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element::model方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionexcelFileOutput14
public function actionexcelFileOutput14($id, $issueId)
{
Yii::import('ext.phpexcel.XPHPExcel');
$columnCont = 1;
$rowCont = 1;
$newsheet = XPHPExcel::createPHPExcel();
$element = Element::model()->findByPk($id);
$i = 4;
$r = 0;
$resCol = Value::model()->findAll("elementId={$id} and colonne=1");
foreach ($element->columns as $colonne) {
$newsheet->getActiveSheet()->setCellValueByColumnAndRow($columnCont, 1, $colonne->value);
$i++;
$columnCont++;
}
foreach ($element->rows as $row) {
$rowCont++;
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, $rowCont, $row->value);
for ($index = 0; $index < $columnCont; $index++) {
$res = $element->getResultTableForExcel($issueId, $id, $index, $r);
switch ($res) {
case "off":
$newsheet->getActiveSheet()->setCellValueByColumnAndRow($index + 1, $r + 2, "No");
break;
case "checked":
$newsheet->getActiveSheet()->setCellValueByColumnAndRow($index + 1, $r + 2, "Yes");
break;
default:
}
}
$r++;
}
$newsheet->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
$newsheet->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
$newsheet->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
$newsheet->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
$newsheet->getActiveSheet()->getColumnDimension('E')->setAutoSize(true);
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="myfile.xlsx');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($newsheet, 'Excel2007');
$objWriter->save('php://output');
}
示例2: actionMef
public function actionMef($idTestContext)
{
$sql = "SELECT COUNT(*) FROM test_context_seq WHERE id_test_context = " . $idTestContext;
$numSeqs = Yii::app()->db->createCommand($sql)->queryScalar();
if ($numSeqs > 0) {
$this->redirect("/mtcontrool/index.php/testContext/inidashboard?idTestContext=" . $idTestContext);
}
/*
ESTA MATRIZ SERÁ PREENCHIDA NESTA FUNÇÃO E ENCAMINHA PARA O ALGORITIMO.
*/
$matrixElementsInstances = array();
//AQUI É FEITA UMA BUSCA POR TODOS OS ELEMENTOS CADASTRADOS NO BANCO.
$elements = Element::model()->findAll();
$sql_countElements = "SELECT * FROM test_context JOIN element_inst ON (test_context.id = element_inst.id_test_context) WHERE test_context.id={$idTestContext} GROUP BY id_element";
$result_countElements = Yii::app()->db->createCommand($sql_countElements)->queryAll();
$totalElements = 0;
foreach ($result_countElements as $item) {
$totalElements = $totalElements + 1;
}
/*
ESTE FOREACH, PERCORRE TODOS OS ELEMENTOS ENCONTRADOS NA BUSCA ACIMA, E PARA CADA
ELEMENTO, ELE BUSCA TODOS AS INSTANCIAS DE ELEMENTOS QUE ESTÃO RELACIONADAS
AO ELEMENTO DA VEZ NO FOREACH E AO TESTCONTEXT EM QUESTÃO CUJO SEU ID É REEBIDO NESTA
FUNÇÃO POR PARÂMETRO.
*/
foreach ($elements as $item) {
$instances = ElementInst::model()->FindAllByAttributes(array("id_element" => $item->id, "id_test_context" => $idTestContext));
if (sizeof($instances) > 0) {
$matrixElementsInstances[$item->description] = $instances;
}
}
/*
A PARTIR DAQUI VOCÊ PODE COMEÇAR A IMPLEMENTAR SEU ALGORÍTIMO.
*/
# code ....
/*
AQUI É APENAS UM TESTE DE EXIBIÇÃO, PARA QUE VOCÊ VEJA O COMPORTAMENTO DA MATRIZ.
AQUI VOCÊ PODE ENTENDER COMO PERCORRER ESTE ARRAY E CONSEGUIR EXTRAI AS INFORMAÇÕES.
*/
$modelTestContext = TestContext::model()->findByPk($idTestContext);
$vector = new ArrayObject();
foreach ($matrixElementsInstances as $key => $element) {
$vectorHelper = new Vetores();
$vectorHelper->title = $key;
foreach ($element as $model) {
$vectorHelper->putElement($model);
}
$vector->append($vectorHelper);
}
//GERAR TABELA e XML
//Inicializa Class Helper passando os vetores para estruturar o xml e a tabela
$xmlGerator = new Helper($vector);
$rawData = array();
//condição que espera um parametro xml na URL
if (isset($_GET['xml'])) {
//ElementsParalax() retorna um array com o schema do xml já trabalhado
$schema = $xmlGerator->ElementsParalax();
//prepara o xml e inicia o download passando o schema e o título
$this->BuildXml($schema, $modelTestContext->description);
} else {
//ElementsParalaxTable() retorna um array com os objetos já trabalhados contendo todo o modelo passado pelo BD
$schema = $xmlGerator->ElementsParalaxTable();
//mostrar para o raphael a construção da tabela
//
//inicia a construção da tabela
$part1 = '<table border="1" style="width:100%">';
$part2 = $part1 . "<tr><th>Variations</th><th>Behavior</th><th>Screenshots</th></th>";
$totalTests = 0;
$partBody = null;
$contaOrdem = 1;
foreach ($schema as $row) {
$variatins = "";
$behavior = "";
$screen = "";
$x = 1;
foreach ($row as $model) {
//print_r($model);
//$model é uuma instância de ELEMENT_INST
//echo $model->iDELEMENT->DESCRIPTION;
$variatins .= $model->iDELEMENT->description . ": " . $model->description;
if ($model->element_type == "interval") {
$variatins .= " (START = " . $model->start_param . "; END = " . $model->end_param . ")";
}
$variatins .= "\n";
$behavior .= $model->behavior . ", ";
if ($model->behavior_screen != "") {
$screen .= $model->behavior_screen;
}
$x++;
}
$rowData = array($contaOrdem, $xmlGerator->str_lreplace(",", "", $variatins), "", "");
$contaOrdem = $contaOrdem + 1;
array_push($rawData, $rowData);
}
$part4 = $part2 . $partBody . "</table>";
}
/*
ARQUI SERÁ A CHAMADA PARA A FUNÇÃO QUE MONTARA O XML.
*/
$nomePlataforma = Platforms::model()->findByPk($modelTestContext->id_platform);
//.........这里部分代码省略.........
示例3: sizeof
<p class="help-block">Fields with <span class="required">*</span> are required.</p>
<div>
<?php
$j = 0;
$tamanho = sizeof($arrayModels);
$anterior = "";
$proximo = "";
?>
<?php
for ($i = 0; $i < $tamanho; $i++) {
?>
<?php
$name = Element::model()->findByPK($arrayModels[$i]->id_element);
?>
<?php
if ($name->description != $anterior) {
?>
<p class="labelCapiroto"><?php
echo $name->description . " (" . $arrayModels[$i]->element_type . ")";
?>
</p>
<table class="table_do_capiroto">
<?php
}
?>
<?php
echo $form->errorSummary($arrayModels[$i]);
示例4: getElement
public function getElement($id)
{
return Element::model()->findByPk($id);
}
示例5: reorder
public function reorder()
{
$elements = Element::model()->findAll("stepId = {$this->stepId} AND position > {$this->position}");
if ($elements) {
foreach ($elements as $element) {
$element->position--;
$element->save();
}
}
}
示例6: array
<?php
echo $form->errorSummary($model);
?>
<tr>
<!--<td><input class="input" type="checkbox" name="option" value="estado" unchecked onchange="valida()" id='chk<?php
//echo "[$i]";
?>
' /> </td>-->
<td><input type="checkbox" name="option" value="estado" unchecked onchange="valida($(this).parent().parent())" id='chk<?php
echo "[{$i}]";
?>
' /> </td>
<td>
<?php
$name = Element::model()->findByPK($model->ID_ELEMENT);
echo "<b>" . $name->DESCRIPTION . "<b/>";
?>
</td>
<td><?php
echo $form->dropDownListControlGroup($model, "[{$i}]ELEMENT_TYPE", $arrayElementType, array('id' => "type_field[{$i}]", 'empty' => '--- Choose a type ---', 'onchange' => "Hab({$i})"));
?>
</td>
<!-- <td><?php
echo $form->textFieldControlGroup($model, "[{$i}]ID_ELEMENT", array('id' => "id_element_field[{$i}]", 'span' => 5));
?>
</td>
<td><?php
echo $form->textFieldControlGroup($model, "[{$i}]ID_TEST_CONTEXT", array('id' => "id_test_context_field[{$i}]", 'span' => 5));
示例7: actionUpdate1
public function actionUpdate1()
{
//SEGUNDA TELA NO UPDATE DE UM TEST CONTEXT
//VERIFICA SE EXISTEM ELEMENTOS QUE AINDA NÃO FORAM USADOS.
//CASO NÃO EXISTAM MAIS ELEMENTOS DISPONÍVEIS, ELE REDIRECIONA AUTOMATICAMNETE PARA A TERCEIRA TELA.
$idTestContext = Yii::app()->user->getState('idTestContext');
$idDevice = Yii::app()->user->getState('idDevice');
//BOTÃO CANCELAR
if (isset($_POST['buttonCancel'])) {
$this->redirect("/mtcontrool/index.php/testContext/admin");
}
$arrayModels = ElementInst::model()->findAll('id_test_context=' . $idTestContext);
$arrayTypes = array();
foreach ($arrayModels as $item) {
$item->sent = $item->behavior_screen;
$arrayTypes[$item->id_element] = $item->element_type;
}
//FUNÇÃO CALLBACK DE ORDENAÇÃO.
function order($a, $b)
{
$retval = strnatcmp($a['id_element'], $b['id_element']);
if (!$retval) {
return strnatcmp($b['description'], $a['description']);
}
return $retval;
}
//VERIFICA QUAIS ELEMENTOS ESTÃO ASSICIADOS AO DEVIDE.
//E CRIA UM NOVO FORM PARA CADA UM DESSES ELEMENTOS
//ISSO PERMITIRÁ QUE NOVAS INSTANCIA DE ELEMENTOS SEJAM CRIADAS.
$arrayExclude = array();
$flag = 0;
$exclude = null;
$elements = new Element();
$elements = Element::model()->with('elementDevices')->findAll('ID_DEVICE=' . $idDevice);
if (sizeof($arrayModels) > 0) {
//$elements=Element::model()->with('elementDevices')->findAll('ID_DEVICE=' . $idDevice);
foreach ($elements as $i => $element) {
$model = new ElementInst();
$model->id_element = $element->id;
$model->id_test_context = $idTestContext;
foreach ($arrayTypes as $key => $value) {
if ($model->id_element == $key) {
$model->element_type = $value;
}
}
if ($model->element_type != '') {
array_push($arrayExclude, $element->id);
} else {
$flag = 1;
}
array_push($arrayModels, $model);
}
//ORDENA O ARRAY DE MODELOS DE FORMA QUE OS MODELOS NÃO PREENCHIDOS FIQUEM POR ULTIMO.
usort($arrayModels, 'order');
$exclude = json_encode($arrayExclude);
if (sizeof($arrayExclude) > 0 and $flag == 1) {
//$this->redirect(Yii::app()->createUrl("/elementInst/create", array("idTestContext"=>$idTestContext,"idDevice"=>$idDevice,"exclude"=>$arrayExclude)));
}
} else {
//$this->redirect(Yii::app()->createUrl("/elementInst/create", array("idTestContext"=>$idTestContext,"idDevice"=>$idDevice)));
}
$arrayExcluded = array();
if ($exclude != null) {
$exclude = json_decode($exclude);
foreach ($elements as $key => $item) {
foreach ($exclude as $value) {
if ($item->id == $value) {
array_push($arrayExcluded, $elements[$key]);
unset($elements[$key]);
}
}
}
$elements = array_values($elements);
}
$listElements = CHtml::listData($elements, 'id', 'description');
$dataProvider = new CActiveDataProvider('Element');
$dataProvider->setData($elements);
//ORDENA O ARRAY DE MODELOS DE FORMA QUE OS MODELOS NÃO PREENCHIDOS FIQUEM POR ULTIMO.
usort($arrayModels, 'order');
$count_elements = 0;
foreach (array_keys($_POST) as $key) {
if (strpos($key, "ElementInst") === 0) {
//Key matches, test value.
$count_elements++;
}
}
//SALVA OS DADOS NO BANCO DE DADOS
$count_saved = 0;
if ($count_elements > 0) {
foreach ($arrayModels as $key => $model) {
if (isset($_POST["description" . $key])) {
if (trim($_POST["description" . $key]) != "") {
$model->description = $_POST["description" . $key];
if ($model->element_type == "interval") {
$model->start_param = $_POST["start_param" . $key];
$model->end_param = $_POST["end_param" . $key];
}
if ($model->save()) {
$count_saved++;
} else {
//.........这里部分代码省略.........
示例8: actionexcelComp
public function actionexcelComp($id, $elementId)
{
//issueId and elementId
$element = Element::model()->findByPk($elementId);
Yii::import('ext.phpexcel.XPHPExcel');
$title = Element::model()->findByPk($elementId);
$newsheet = XPHPExcel::createPHPExcel();
switch ($element->typeId) {
case 0:
case 1:
case 3:
case 4:
$criteria = "elementId={$elementId}";
$results = Result::model()->findAll($criteria);
//$results=Result::model()->findAll($title->label);
$newsheet->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$newsheet->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$newsheet->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$newsheet->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, 1, "Issue ID");
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(1, 1, "User");
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(2, 1, "Fill date");
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(3, 1, $title->label);
$newsheet->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$newsheet->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$newsheet->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$newsheet->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$newsheet->getActiveSheet()->getStyle('A1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
$newsheet->getActiveSheet()->getStyle('B1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
$newsheet->getActiveSheet()->getStyle('C1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
$newsheet->getActiveSheet()->getStyle('D1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
$newsheet->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
$newsheet->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
$newsheet->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
$newsheet->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
$cont = 2;
foreach ($results as $result) {
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, $cont, $result->issueId);
$issue = $this->loadIssue($result->issueId);
$user = Element::model()->getUserForExcel($result->issueId, $elementId);
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(1, $cont, $user);
//
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(2, $cont, Yii::app()->dateFormatter->format("HH:mm d/M/y", $result->createTime));
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(3, $cont, $result->value);
$cont++;
}
$traveler = Traveler::model()->findByPk($issue->travelerId);
if (isset($issue)) {
if (strlen($traveler->name) > 28) {
$traveler->name = substr($traveler->name, 0, 28);
}
$newsheet->getActiveSheet()->setTitle($traveler->name);
}
//else throw new CHttpException(403, 'There is a problem with the data');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="myfile.xlsx');
header('Cache-Control: max-age=0');
//metada:
$newsheet->getProperties()->setCreator(Yii::app()->user->username);
$objWriter = PHPExcel_IOFactory::createWriter($newsheet, 'Excel2007');
$objWriter->save('php://output');
break;
case 5:
//devuelve el value de result, que es el id de value!!
//center 1st column
$newsheet->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$newsheet->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$newsheet->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$newsheet->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//name first column
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, 1, "Issue ID");
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(1, 1, "User");
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(2, 1, "Fill date");
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(3, 1, $title->label);
//center data cells
$newsheet->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$newsheet->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$newsheet->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$newsheet->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
//color
$newsheet->getActiveSheet()->getStyle('A1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
$newsheet->getActiveSheet()->getStyle('B1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
$newsheet->getActiveSheet()->getStyle('C1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
$newsheet->getActiveSheet()->getStyle('D1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('AFDBFF');
//size
$newsheet->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
$newsheet->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
$newsheet->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
$newsheet->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
$criteria = "elementId={$elementId}";
$preresults = Result::model()->findAll($criteria);
$cont = 2;
foreach ($preresults as $preresult) {
$issue = $this->loadIssue($preresult->issueId);
$user = Element::model()->getUserForExcel($preresult->issueId, $elementId);
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(0, $cont, $preresult->issueId);
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(1, $cont, $user);
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(2, $cont, Yii::app()->dateFormatter->format("HH:mm d/M/y", $preresult->createTime));
$value = Value::model()->findByPk($preresult->value);
$newsheet->getActiveSheet()->setCellValueByColumnAndRow(3, $cont, $value->value);
//.........这里部分代码省略.........
示例9: array
?>
<?php
$listRemove = array();
?>
<?php
$listOpen = array();
?>
<?php
foreach ($arrayModels as $key => $model) {
?>
<input type="hidden" name="ElementInst<?php
echo $acc_id;
?>
">
<?php
$name = Element::model()->findByPK($model->id_element);
?>
<?php
if ($name->description != $anterior) {
?>
<div class="labels">
<?php
if ($key > 0) {
?>
<br>
<?php
$contaLinha = 1;
?>
<?php
}
?>
示例10: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Element the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Element::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例11: sortElement
public function sortElement($position)
{
$i = 1;
foreach ($position as $id) {
$element = Element::model()->findByPk($id);
$element->position = $i;
$element->save();
$i++;
}
}