Esempio n. 1
0
		<?php
	}
	else
	{
		$bkp = $bindKeysParent;
		array_push($bkp, $bindKeys);
		foreach($iframes as $iframe)
		{
			?>
			<div class="item">
				<?php
				echo CHtml::tag('iframe', array(
					'src' => AAHelperUrl::update(Yii::app()->request->requestUri, 
						array('id', 'action'),
						array(
								'foreign'	=> $iframe['action'],
								'bkp'		=> $bkp,
								'bk'		=> $fields->pk,
							)
					)), null, true);
				if(!empty($iframe['foreign']->description))
				{
					?><div class="desc"><?php echo $iframe['foreign']->description?></div><?php
				}
				?>
			</div>
			<?php
		}
	}
}
echo CHtml::submitButton(Yii::t('AutoAdmin.common', 'Save'), array('name'=>null));
Esempio n. 2
0
	/**
	 * Executes direct processing of state and activate internal methods.
	 * Must be called only at the very end of a controller method.
	 */
	public function process()
	{
		if(!isset($this->_access))
			$this->initAccess();
		$this->loadPk();
		if(!$this->testConf())
			throw new AAException(Yii::t('AutoAdmin.errors', 'Incorrect configuration'));
		$this->_viewData = array_merge($this->_viewData, array(
			'rights'	=> $this->_access->exportRights(),
			'pk'		=> $this->_data->pk,
			'partialViews'	=> $this->partialViews,
			'clientData'	=> $this->clientViewData,
			'interface'		=> $this->_interface,
			'bindKeys'		=> Yii::app()->request->getParam('bk', array()),
			'bindKeysParent'=> Yii::app()->request->getParam('bkp', array()),
			'manageAction'	=> &$this->_manageAction,
		));

		switch($this->_manageAction)
		{
			case 'add':	//Form for data adding
			{
				if(!$this->_access->checkRight('add'))
					$this->blockAccess();
				$this->editMode();
				break;
			}
			case 'edit':	//Form for data editing
			{
				if(!$this->_access->checkRight('edit'))
					$this->blockAccess();
				$this->editMode();
				break;
			}
			case 'insert':	//Process inserting data in DB
			{
				if(!$this->_access->checkRight('add'))
					$this->blockAccess();
				$affected = $this->insert();
				$this->resultMode(array('msg'=>Yii::t('AutoAdmin.messages', ($affected ? 'The record was added' : 'The record was not added'))));
				break;
			}
			case 'update':	//Process updating data in DB
			{
				if(!$this->_access->checkRight('edit'))
					$this->blockAccess();
				$affected = $this->update();
				$this->resultMode(array('msg'=>Yii::t('AutoAdmin.messages', ($affected ? 'The record has been changed' : 'The record has not been changed'))));
				break;
			}
			case 'delete':	//Process deletion data in DB
			{
				if(!$this->_access->checkRight('delete'))
					$this->blockAccess();
				$deletingRow = $this->_db->getCurrentRow();
				if(!$deletingRow)
					throw new CHttpException(404, Yii::t('AutoAdmin.errors', 'Can\'t find the record'));

				if($this->confirmDelete && !Yii::app()->request->getPost('sure', false))
				{
					$confirmUrl = AAHelperUrl::update(Yii::app()->request->requestUri, array('action'), array('action'=>'delete'));
					$cancelUrl = AAHelperUrl::stripParam(Yii::app()->request->requestUri, array('action'));
					foreach($this->_data->pk as $pkField=>$value)
						$cancelUrl = AAHelperUrl::stripParam($cancelUrl, "id[{$pkField}]");
					foreach($this->_data->fields as $k=>&$field)
						$field->value = $deletingRow->fields[$k]->value;
					$this->_controller->render($this->viewsPath.'confirmDelete', array('confirmUrl'=>$confirmUrl, 'cancelUrl'=>$cancelUrl, 'fields'=>$this->_data->fields));
					Yii::app()->end();
				}
				else
				{
					$affected = $this->delete($deletingRow);
					$this->resultMode(array('msg'=>Yii::t('AutoAdmin.messages', ($affected ? 'The record was deleted' : 'The record has not been deleted'))));
				}
				break;
			}
			case 'upload':	//Uploading a file for field
			{
				if(!$this->_access->checkRight('edit'))
					$this->blockAccess();
				$viewData = array('field'=>Yii::app()->request->getParam('field'));
				if(!empty($_POST[self::INPUT_PREFIX]['upload']) && !empty($_FILES[self::INPUT_PREFIX]['name']['uploadFile']))
				{
					$upload = $_POST[self::INPUT_PREFIX]['upload'];
					if(preg_match('/'.self::INPUT_PREFIX.'\[([^\]]+)\]$/', $upload['field'], $matches))
					{
						$field = $this->_data->getFieldByName($matches[1]);
						if(!isset($field->options['directoryPath']))
							throw new AAException(Yii::t('AutoAdmin.errors', 'The parameter "{paramName}" must be set for the field {fieldName}', array('parameter'=>'directoryPath', '{fieldName}'=>$field->name)));
						$uploadDir = $field->options['directoryPath'];
						if($field->options['subDirectoryPath'])
							$uploadDir .= '/'.$field->options['subDirectoryPath'];
						
						$viewData['uploadedFileName'] = AAHelperFile::uploadFile('uploadFile', $uploadDir);
						$viewData['uploadedFileAbs'] = Yii::app()->basePath.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.Yii::app()->modules['autoadmin']['wwwDirName'].str_replace('/', DIRECTORY_SEPARATOR, $uploadDir).DIRECTORY_SEPARATOR.$viewData['uploadedFileName'];
						$viewData['uploadedFileSrc'] = "{$uploadDir}/{$viewData['uploadedFileName']}";
						$viewData['alt'] = !empty($upload['alt']) ? $upload['alt'] : '';
						$viewData['fieldName'] = $field->formInputName();
					}
				}
				$this->_controller->layout = 'ext.autoadmin.views.layouts.fileUpload';
				$this->_controller->render($this->viewsPath.'fileUpload', $viewData);
				break;
			}
			case 'empty':	//Interface which is programmed directly by user
			{
				if(!$this->_access->checkRight('read'))
					$this->blockAccess();
				$this->_controller->render($this->viewsPath.'empty', $this->_viewData);
				break;
			}
			default:	//Data list show (default mode)
			{
				if(!$this->_access->checkRight('read'))
					$this->blockAccess();
				$this->listMode();
				break;
			}
		}
	}
Esempio n. 3
0
<?php
$actionURL = AAHelperUrl::update($baseURL, array('searchQ', 'searchBy'));
$getParams = AAHelperUrl::uriToParamsArray($actionURL);
if($getParams)
	$actionURL = AAHelperUrl::update($actionURL, array_keys($getParams));
echo CHtml::form($actionURL, 'get', array('id'=>'search-panel'));
foreach($getParams as $param=>$value)
	echo CHtml::hiddenField($param, $value);
echo CHtml::label(Yii::t('AutoAdmin.common', 'Search').':', 'searchQ');
echo CHtml::textField('searchQ', (isset($searchOptions['query']) && !is_array($searchOptions['query']) ? $searchOptions['query'] : ''), array('id'=>'searchQ'));

$inSearch = array();
$selectedIndex = null;

foreach($fields as $k=>$field)
{
	if(!empty($field->options['inSearch']))
	{
		$inSearch[$k] = $field->label;
		if(!empty($searchOptions['field']) && $searchOptions['field']->name == $field->name)
			$selectedIndex = $k;
	}
}
echo CHtml::dropDownList('searchBy', $selectedIndex, $inSearch);
echo CHtml::submitButton('OK', array('name'=>null, 'title'=>Yii::t('AutoAdmin.common', 'Search')));
echo CHtml::resetButton(Yii::t('AutoAdmin.common', 'Reset'), array('name'=>null, 'title'=>Yii::t('AutoAdmin.common', 'Reset')));

echo CHtml::closeTag('form');
?>