我的编辑.php文件中$this变量是什么意思? 其他文件中没有"包含"或"要求"!我的意思是我怎样才能找到$this所指的类。其中是包含使用此编辑.php文件的类的主 PHP 文件
编辑.php
<?php
/**
* @package RSForm! Pro
* @copyright (C) 2007-2014 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.keepalive');
?>
<script type="text/javascript">
function directorySave(task) {
var form = document.getElementById('directoryEditForm');
form.task.value = task;
form.submit();
}
</script>
<form action="<?php echo JRoute::_('index.php? option=com_rsform&view=directory&layout=edit&id='.$this->app->input->getInt('id',0)); ?>" method="post" name="adminForm" id="directoryEditForm" enctype="multipart/form-data">
<table class="table table-condensed table-striped table-hover table-bordered category">
<?php foreach ($this->fields as $field) { ?>
<tr>
<td width="200" style="width: 200px;">
<?php echo $field[0]; ?> <?php echo $field[2]; ?>
</td>
<td>
<?php echo $field[1]; ?>
</td>
</tr>
<?php } ?>
</table>
<div class="form-actions">
<button type="button" onclick="directorySave('apply');" class="btn btn-primary button"><?php echo JText::_('RSFP_SUBM_DIR_APPLY'); ?></button>
<button type="button" onclick="directorySave('save');" class="btn btn-primary button"><?php echo JText::_('RSFP_SUBM_DIR_SAVE'); ?></button>
<button type="button" onclick="directorySave('back')" class="btn button"><?php echo JText::_('RSFP_SUBM_DIR_BACK'); ?></button>
<?php /* <--! I am Ahmad Mobaraki --> */?>
<button type="button" onclick="directorySave('delete')" class="btn btn-primary button"><?php echo JText::_('RSFP_SUBM_DIR_DELETE'); ?></button>
<?php /* end ahmad*/ ?>
</div>
<input type="hidden" name="option" value="com_rsform">
<input type="hidden" name="controller" value="directory">
<input type="hidden" name="task" value="">
<input type="hidden" name="id" value="<?php echo $this->app->input->getInt('id',0); ?>">
<input type="hidden" name="formId" value="<?php echo $this->params->get('formId'); ?>">
</form>
如果它在视图文件夹的tmpl文件夹中,则它指的是JView/JViewLegacy/JViewBase类或任何扩展视图类。通常,该类将在视图中的父文件夹中定义.html.php或类似名称的文件。
如果你做一个$this var_dump它会告诉你类名
例如,如果我这样做
var_dump($this); die;
在我的一个视图模板文件中,我得到
对象(退伍军人查看退伍军人(#190.....
其中VeteransViewVeterans
是我的退伍军人视图的退伍军人视图的视图类。
$this
保存视图类引用,因为它是包含/需要它的类