本文整理汇总了PHP中CHtml::script方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::script方法的具体用法?PHP CHtml::script怎么用?PHP CHtml::script使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::script方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreadestinatario
public function actionCreadestinatario($id)
{
$model = new Mensajesd();
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
if (isset($_POST['Mensajesd'])) {
$model->attributes = $_POST['Mensajesd'];
if ($model->save()) {
if (!empty($_GET['asDialog'])) {
//Close the dialog, reset the iframe and update the grid
echo CHtml::script("window.parent.\$('#cru-dialog').dialog('close');window.parent.\$('#cru-frame').attr('src','');window.parent.\$.fn.yiiGridView.update('{$_GET['gridId']}');");
Yii::app()->end();
}
} else {
throw new CHttpException(404, 'No se pudo grabar el destinatario');
}
//----- begin new code --------------------
//if (!empty($_GET['asDialog']))
$this->layout = '//layouts/iframe';
//----- end new code --------------------
}
if (!empty($_GET['asDialog'])) {
$this->layout = '//layouts/iframe';
}
$this->render('_form_destintario', array('model' => $model, 'id' => $id));
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($idobservacion)
{
$model = new Observacionesdetalle();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Observacionesdetalle'])) {
$model->attributes = $_POST['Observacionesdetalle'];
$model->hidobservaciones = $idobservacion;
$model->usuario = Yii::app()->user->name;
$model->fecha = date("d-m-Y H:i:s");
if ($model->save()) {
$modeloinventario = Observaciones::model()->findByPk($idobservacion);
}
if (!$this->enviamail($modeloinventario, $model->comentario)) {
echo "fallo";
yii::app()->end();
}
$model->refresh();
if (!empty($_GET['asDialog'])) {
//Close the dialog, reset the iframe and update the grid
echo CHtml::script("window.parent.\$('#cru-dialog1').dialog('close');\n\t\t\t\t\t\t\t\t\t\t\t\t\t window.parent.\$('#cru-frame1').attr('src','');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twindow.parent.\$.fn.yiiGridView.update('{$_GET['gridId']}');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
Yii::app()->end();
}
$this->render('Confirma', array('id' => $model->id));
Yii::app()->end();
//$this->redirect(array('view','id'=>$model->id));
}
$this->layout = '//layouts/iframe';
$this->render('create', array('model' => $model, 'idobservacion' => $idobservacion));
}
示例3: actionLogin
public function actionLogin()
{
if (isset($_POST['token'])) {
$this->networkLogin();
}
$this->layout = null;
$this->breadCrumbs = array('Управление сайтом' => array('/users/default/siteManagment'));
$form = new LoginForm();
if (isset($_POST['LoginForm'])) {
$form->attributes = $_POST['LoginForm'];
if ($form->validate()) {
$backUrl = $form->getBackUrl();
if (Yii::app()->getRequest()->getIsAjaxRequest()) {
echo CHtml::script("document.location='" . $backUrl . "'");
return;
} else {
$this->redirect($backUrl);
}
}
}
if (Yii::app()->getRequest()->getIsAjaxRequest()) {
$this->renderPartial('form/login', array('form' => $form, 'backUrl' => $backurl));
} else {
$this->render('login', array('user' => $form, 'backUrl' => $backurl));
}
}
示例4: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($idinventario)
{
$model = new Observaciones();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Observaciones'])) {
$model->attributes = $_POST['Observaciones'];
//$model->usuario=Yii::app()->getModule('user')->user()->username;
$modelitoactivo = Inventario::model()->findByPk($model->hidinventario);
$model->codestado = '10';
if ($model->save()) {
// echo "salio";
$this->enviamail($modelitoactivo, $model);
}
$model->refresh();
if (!empty($_GET['asDialog'])) {
//Close the dialog, reset the iframe and update the grid
echo CHtml::script("window.parent.\$('#cru-dialog').dialog('close');\n\t\t\t\t\t\t\t\t\t\t\t\t\t window.parent.\$('#cru-frame').attr('src','');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twindow.parent.\$.fn.yiiGridView.update('{$_GET['gridId']}');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
Yii::app()->end();
}
$this->render('Confirma', array('id' => $model->id));
Yii::app()->end();
}
$modeloinventario = Inventario::model()->findByPk($idinventario);
$fot = new Fotos($modeloinventario->codigosap, Yii::app()->params['rutafotosinventario'], '.JPG');
$misfotos = $fot->devuelveFotos();
if (!empty($_GET['asDialog'])) {
$this->layout = '//layouts/iframe';
}
$this->render('create', array('model' => $model, 'modeloinventario' => $modeloinventario, 'misfotos' => $misfotos, 'ruta' => Yii::app()->params['rutafotosinventario_'], 'fot' => $fot));
}
示例5: registerClientScript
public function registerClientScript()
{
$cs = Yii::app()->clientScript;
$id = $this->imageOptions['id'];
$url = $this->getController()->createUrl($this->captchaAction, array(CCaptchaAction::REFRESH_GET_VAR => true));
$js = "";
if ($this->showRefreshButton) {
// reserve a place in the registered script so that any enclosing button js code appears after the captcha js
// $cs->registerScript('Yii.CCaptcha#' . $id, '// dummy');
echo CHtml::script('// dummy');
$label = $this->buttonLabel === null ? Yii::t('yii', 'Get a new code') : $this->buttonLabel;
$options = $this->buttonOptions;
if (isset($options['id'])) {
$buttonID = $options['id'];
} else {
$buttonID = $options['id'] = $id . '_button';
}
if ($this->buttonType === 'button') {
$html = CHtml::button($label, $options);
} else {
$html = CHtml::link($label, $url, $options);
}
$js = "jQuery('#{$id}').after(" . CJSON::encode($html) . ");";
$selector = "#{$buttonID}";
}
if ($this->clickableImage) {
$selector = isset($selector) ? "{$selector}, #{$id}" : "#{$id}";
}
if (!isset($selector)) {
return;
}
$js .= "\njQuery(document).on('click', '{$selector}', function(){\n\tjQuery.ajax({\n\t\turl: " . CJSON::encode($url) . ",\n\t\tdataType: 'json',\n\t\tcache: false,\n\t\tsuccess: function(data) {\n var url = data['url'].split('?v=');\n var newCode = url[url.length - 1];\n var imgSrc = jQuery('#{$id}').attr('src').split('/');\n var oldCode = imgSrc[imgSrc.length - 1];\n var newUrl = jQuery('#{$id}').attr('src').replace(oldCode, newCode);\n \n\t\t\tjQuery('#{$id}').attr('src', newUrl);\n\t\t\tjQuery('body').data('{$this->captchaAction}.hash', [data['hash1'], data['hash2']]);\n\t\t}\n\t});\n\treturn false;\n});\n";
// $cs->registerScript('Yii.CCaptcha#' . $id, $js);
echo CHtml::script($js);
}
示例6: generateBasepath
/**
* Generate script code for CKEditor basepath definition.
* @return string Generated script code.
*/
public static function generateBasepath()
{
$CKEditorExtPath = dirname(dirname(__FILE__)) . '/vendors/CKEditor';
$CKEditorUrl = CJavaScript::encode(Yii::app()->assetManager->getPublishedUrl($CKEditorExtPath) . '/');
$script = "var CKEDITOR_BASEPATH = {$CKEditorUrl};";
return CHtml::script($script);
}
示例7: actionRecibevalor
public function actionRecibevalor()
{
$autoIdAll = array();
if (isset($_GET['checkselected'])) {
$autoIdAll = $_GET['checkselected'];
///The records selecteds
}
if (count($autoIdAll) > 0) {
echo CHtml::script("window.parent.\$('#cru-dialog3').dialog('close');\t\t\t\t\t\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twindow.parent.\$('#cru-frame3').attr('src','');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar caja=window.parent.\$('#cru-dialog3').data('hilo');\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar valoresclave= new Array();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar cadenita='{$autoIdAll[0]}';\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar valoresclave=cadenita.split('_');\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twindow.parent.\$('#'+caja+'').attr('value',valoresclave[0]);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twindow.parent.\$('#'+caja+'_99').html(valoresclave[1]);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
Yii::app()->end();
} else {
$campo = $_GET['campo'];
$relaciones = $_GET['relaciones'];
//$modeliz=new MaestroGrupos;
//$relaciones=$modeliz->relations();
$nombreclase = Yii::app()->explorador->nombreclase($campo, $relaciones);
//$tipodato=gettype(Yii::app()->explorador->devuelvemodelo($campo,$relaciones));
$model = Yii::app()->explorador->devuelvemodelo($campo, $relaciones);
$model->unsetAttributes();
if (isset($_GET[$nombreclase])) {
$model->attributes = $_GET[$nombreclase];
}
$this->layout = '//layouts/iframe';
$this->render("ext.explorador.views.vw_" . $nombreclase, array('model' => $model));
//$this->render("ext.explorador.views.vw_pruebitas1",array('tipodato'=>$tipodato,'tablita'=>$nombreclase,'campo'=>$campo,'relaciones'=>$relaciones));
}
}
示例8: actionView
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
if (Yii::app()->request->isAjaxRequest) {
//outputProcessing = true because including css-files ...
$this->renderPartial('view', array('model' => $this->loadModel($id)), false, true);
//js-code to open the dialog
if (!empty($_GET['asDialog'])) {
echo CHtml::script('$("#dialog_id").dialog("open").dialog( { title: "Detail View" } )');
}
Yii::app()->end();
} else {
$this->render('view', array('model' => $this->loadModel($id)));
}
}
示例9: renderOnRequest
/**
* Inserts the scripts at the beginning of the body section.
* @param string the output to be inserted with scripts.
*/
public function renderOnRequest()
{
$html = '';
foreach ($this->scriptFiles as $scriptFiles) {
foreach ($scriptFiles as $scriptFile) {
$html .= CHtml::scriptFile($scriptFile) . "\n";
}
}
foreach ($this->scripts as $script) {
$html .= CHtml::script(implode("\n", $script)) . "\n";
}
if ($html !== '') {
return $html;
}
}
示例10: redirect
/**
* override needed to check if its ajax, the redirect will be by javascript
*/
public function redirect($url, $terminate = true, $statusCode = 302)
{
if (!Yii::app()->getRequest()->getIsAjaxRequest()) {
return parent::redirect($url, $terminate, $statusCode);
} else {
if (is_array($url)) {
$route = isset($url[0]) ? $url[0] : '';
$url = $this->createUrl($route, array_splice($url, 1));
}
echo CHtml::script("window.top.location='{$url}'");
if ($terminate) {
Yii::app()->end($statusCode);
}
}
}
示例11: init
public function init()
{
$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'media';
$url = Yii::app()->getAssetManager()->publish($path);
$imgUrl = $url . '/print.png';
echo CHtml::link("<i class='icon-white icon-print'></i> Imprimir", "#", array_merge($this->htmlOptions, array('onclick' => 'return processPrint();', 'class' => 'btn btn-info')));
self::$count++;
if (self::$count == 1) {
$cs = Yii::app()->getClientScript();
$cs->registerCssFile($url . '/' . $this->cssFile);
Yii::app()->clientScript->registerCoreScript('jquery');
echo CHtml::script("\n var firstTime = true;\n function processPrint()\n {\n if (firstTime) {\n \$('{$this->coverElement}').addClass('printWidgetScreenCover');\n \n title = '{$this->title}';\n if (title != '')\n \$('<h3 class=\\'printWidgetPrintedElement\\'>'+title+'</h3>').appendTo('body');\n \n arrayEl = \$('{$this->printedElement}').get();\n for (var i=0; i<arrayEl.length; i++) {\n clonedEl = \$(arrayEl[i]).clone();\n \$(clonedEl).find('a').removeAttr('href');\n clonedEl.addClass('printWidgetPrintedElement');\n clonedEl.appendTo('body');\n }\n \n firstTime = false;\n }\n \$('{$this->coverElement}').addClass('printWidgetScreenCover');\n window.print();\n return false;\n }\n ");
echo CHtml::css("\n .printWidgetScreenCover {display: none;}\n .printWidgetPrintedElement {display: block; margin: 0px;}\n ", "print");
echo CHtml::css("\n .printWidgetPrintedElement {display: none;}\n ", "screen");
}
}
示例12: init
public function init()
{
$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'media';
$url = Yii::app()->getAssetManager()->publish($path);
$imgUrl = $url . '/print.gif';
echo CHtml::link("<img src=\"{$imgUrl}\" class=\"img_link\" title=\"" . Yii::t('lms', 'print') . "\">", "#", array_merge($this->htmlOptions, array('onclick' => 'return processPrint();')));
self::$count++;
if (self::$count == 1) {
$cs = Yii::app()->getClientScript();
$cs->registerCssFile($url . '/' . $this->cssFile);
Yii::app()->clientScript->registerCoreScript('jquery');
echo CHtml::script("\n var firstTime = true;\n function processPrint()\n {\n if (firstTime) {\n \$('{$this->coverElement}').addClass('printWidgetScreenCover');\n \n title = '{$this->title}';\n if (title != '')\n \$('<h3 class=\\'printWidgetPrintedElement\\'>'+title+'</h3>').appendTo('body');\n \n arrayEl = \$('{$this->printedElement}').get();\n for (var i=0; i<arrayEl.length; i++) {\n clonedEl = \$(arrayEl[i]).clone();\n clonedEl.addClass('printWidgetPrintedElement');\n clonedEl.appendTo('body');\n }\n \n firstTime = false;\n }\n window.print();\n return false;\n }\n ");
echo CHtml::css("\n .printWidgetScreenCover {display: none;}\n .printWidgetPrintedElement {display: block; padding-top:15px;margin-bottom: 0px;margin-top: 0px;margin-left: 20px;margin-right: 20px;}\n ", "print");
echo CHtml::css("\n .printWidgetPrintedElement {display: none;}\n ", "screen");
}
}
示例13: processScripts
public function processScripts($applyList = false)
{
if ($applyList) {
$this->scripts[] = '
placemarksYMap = placemarksAll;
if(typeof list !== "undefined"){
list.apply();
}
';
}
// end of ymaps.ready(function () {
$this->scripts[] = '
});
});
';
// publish scripts
echo CHtml::script(implode("\n", $this->scripts));
}
示例14: renderOnRequest
/**
* Inserts the scripts at the beginning of the body section.
* @param boolean $includeScriptFiles whether to include external files, or just dynamic scripts
* @return string the output to be inserted with scripts.
*/
public function renderOnRequest($includeScriptFiles = false)
{
$html = '';
if ($includeScriptFiles) {
foreach ($this->scriptFiles as $scriptFiles) {
foreach ($scriptFiles as $scriptFile) {
$html .= CHtml::scriptFile($scriptFile) . "\n";
}
}
}
foreach ($this->scripts as $script) {
// the good stuff!
$html .= CHtml::script(implode("\n", $script)) . "\n";
}
if ($html !== '') {
return $html;
}
}
示例15: actionUpdate
public function actionUpdate($id)
{
$model = $this->loadModel($id);
if (isset($_POST['Tenores'])) {
$model->attributes = $_POST['Tenores'];
if ($model->save()) {
if (!empty($_GET['asDialog'])) {
//Close the dialog, reset the iframe and update the grid
echo CHtml::script("window.parent.\$('#cru-dialogdetalle').dialog('close');\n\t\t\t\t\t\t\t\t\t\t\t\t\t window.parent.\$('#cru-detalle').attr('src','');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t window.parent.\$.fn.yiiGridView.update('{$_GET['gridId']}');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
Yii::app()->end();
}
}
$this->redirect(array('view', 'id' => $model->id));
}
if (!empty($_GET['asDialog'])) {
$this->layout = '//layouts/iframe';
}
$this->render('update', array('model' => $model));
}