本文整理汇总了PHP中Template::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Template::model方法的具体用法?PHP Template::model怎么用?PHP Template::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template
的用法示例。
在下文中一共展示了Template::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionPublicList
public function actionPublicList($lang = null)
{
if (!empty($lang)) {
App()->setLanguage($lang);
} else {
App()->setLanguage(App()->getConfig('defaultlang'));
}
$oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate"));
if ($oTemplate->cssFramework == 'bootstrap') {
// We now use the bootstrap package isntead of the Yiistrap TbApi::register() method
// Then instead of using the composer dependency system for templates
// We can use the package dependency system
Yii::app()->getClientScript()->registerMetaTag('width=device-width, initial-scale=1.0', 'viewport');
App()->bootstrap->registerAllScripts();
}
$aData = array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll());
$htmlOut = $this->render('publicSurveyList', $aData, true);
$event = new PluginEvent('beforeSurveysStartpageRender', $this);
$event->set('aData', $aData);
App()->getPluginManager()->dispatchEvent($event);
if ($event->get('result')) {
$htmlFromEvent = $event->get('result');
$htmlOut = $htmlFromEvent['html'];
}
echo $htmlOut;
}
示例2: showsaveform
function showsaveform()
{
//Show 'SAVE FORM' only when click the 'Save so far' button the first time, or when duplicate is found on SAVE FORM.
global $errormsg, $thissurvey, $surveyid, $clienttoken, $thisstep;
$redata = compact(array_keys(get_defined_vars()));
$sTemplatePath = $_SESSION['survey_' . $surveyid]['templatepath'];
sendCacheHeaders();
doHeader();
$oTemplate = Template::model()->getInstance(null, $surveyid);
echo templatereplace(file_get_contents($oTemplate->viewPath . "startpage.pstpl"), array(), $redata);
echo "\n\n<!-- JAVASCRIPT FOR CONDITIONAL QUESTIONS -->\n" . "\t<script type='text/javascript'>\n" . "\t<!--\n" . "function checkconditions(value, name, type, evt_type)\n" . "\t{\n" . "\t}\n" . "\t//-->\n" . "\t</script>\n\n";
echo CHtml::form(array("/survey/index", "sid" => $surveyid), 'post') . "\n";
//PRESENT OPTIONS SCREEN
if (isset($errormsg) && $errormsg != "") {
$errormsg .= "<p>" . gT("Please try again.") . "</p>";
}
echo templatereplace(file_get_contents($oTemplate->viewPath . "save.pstpl"), array(), $redata);
//END
echo "<input type='hidden' name='thisstep' value='{$thisstep}' />\n";
echo CHtml::hiddenField('token', $clienttoken) . "\n";
echo "<input type='hidden' name='saveprompt' value='Y' />\n";
echo "</form>";
echo templatereplace(file_get_contents($oTemplate->viewPath . "endpage.pstpl"), array(), $redata);
echo "</html>\n";
exit;
}
示例3: defaultAttributes
protected function defaultAttributes()
{
$attr = parent::defaultAttributes();
$findParams = \GO\Base\Db\FindParams::newInstance()->limit(1);
$stmt = Template::model()->find($findParams);
if ($template = $stmt->fetch()) {
$attr['template_id'] = $template->id;
}
return $attr;
}
示例4: actionPublicList
public function actionPublicList($lang = null)
{
if (!empty($lang)) {
App()->setLanguage($lang);
} else {
App()->setLanguage(App()->getConfig('defaultlang'));
}
$oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate"));
if ($oTemplate->cssFramework == 'bootstrap') {
App()->bootstrap->register();
}
$this->render('publicSurveyList', array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll()));
}
示例5: _renderHtml
private function _renderHtml($html, $thistpl, $aSurveyInfo)
{
sendCacheHeaders();
doHeader();
$aSupportData = array('thissurvey' => $aSurveyInfo);
$oTemplate = Template::model()->getInstance();
$sTemplatePath = $oTemplate->path;
$thistpl = $oTemplate->viewPath;
echo templatereplace(file_get_contents($thistpl . 'startpage.pstpl'), array(), $aSupportData);
$aData['html'] = $html;
$aData['thistpl'] = $thistpl;
$this->render('/opt_view', $aData);
echo templatereplace(file_get_contents($thistpl . 'endpage.pstpl'), array(), $aSupportData);
doFooter();
}
示例6: _init
/**
* Initialises this controller, does some basic checks and setups
*
* @access protected
* @return void
*/
protected function _init()
{
parent::_init();
App()->getComponent('bootstrap');
$this->_sessioncontrol();
define('ADMIN_SCRIPT_PATH', realpath(Yii::app()->basePath . '/../scripts/admin/') . '/');
define('SCRIPT_PATH', realpath(Yii::app()->basePath . '/../scripts/') . '/');
App()->getClientScript()->registerScriptFile(App()->getAssetManager()->publish(ADMIN_SCRIPT_PATH . '/admin_core.js'));
$this->user_id = Yii::app()->user->getId();
if (!Yii::app()->getConfig("surveyid")) {
Yii::app()->setConfig("surveyid", returnGlobal('sid'));
}
//SurveyID
if (!Yii::app()->getConfig("ugid")) {
Yii::app()->setConfig("ugid", returnGlobal('ugid'));
}
//Usergroup-ID
if (!Yii::app()->getConfig("gid")) {
Yii::app()->setConfig("gid", returnGlobal('gid'));
}
//GroupID
if (!Yii::app()->getConfig("qid")) {
Yii::app()->setConfig("qid", returnGlobal('qid'));
}
//QuestionID
if (!Yii::app()->getConfig("lid")) {
Yii::app()->setConfig("lid", returnGlobal('lid'));
}
//LabelID
if (!Yii::app()->getConfig("code")) {
Yii::app()->setConfig("code", returnGlobal('code'));
}
// ??
if (!Yii::app()->getConfig("action")) {
Yii::app()->setConfig("action", returnGlobal('action'));
}
//Desired action
if (!Yii::app()->getConfig("subaction")) {
Yii::app()->setConfig("subaction", returnGlobal('subaction'));
}
//Desired subaction
if (!Yii::app()->getConfig("editedaction")) {
Yii::app()->setConfig("editedaction", returnGlobal('editedaction'));
}
// for html editor integration
// Variable not used, but keep it here so the object is initialized at the right place.
$oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate"));
}
示例7: run
public function run()
{
/*
* Instead of manually rendering scripts after this function returns we
* use the callback. This ensures that scripts are always rendered, even
* if we call exit at some point in the code. (Which we shouldn't, but
* it happens.)
*/
// Ensure to set some var, but script are replaced in SurveyRuntimeHelper
$aLSJavascriptVar = array();
$aLSJavascriptVar['bFixNumAuto'] = (int) (bool) Yii::app()->getConfig('bFixNumAuto', 1);
$aLSJavascriptVar['bNumRealValue'] = (int) (bool) Yii::app()->getConfig('bNumRealValue', 0);
$aLangData = getLanguageData();
$aRadix = getRadixPointData($aLangData[Yii::app()->getConfig('defaultlang')]['radixpoint']);
$aLSJavascriptVar['sLEMradix'] = $aRadix['separator'];
$sLSJavascriptVar = "LSvar=" . json_encode($aLSJavascriptVar) . ';';
// Template configuration
$param = $this->_getParameters(func_get_args(), $_POST);
$surveyid = $param['sid'];
// Font awesome
if (!YII_DEBUG) {
App()->getClientScript()->registerCssFile(App()->getAssetManager()->publish(dirname(Yii::app()->request->scriptFile) . '/styles-public/font-awesome-43.min.css'));
} else {
App()->getClientScript()->registerCssFile(Yii::app()->getBaseUrl(true) . '/styles-public/font-awesome-43-debugmode.min.css');
}
global $oTemplate;
$oTemplate = Template::model()->getTemplateConfiguration('', $surveyid);
$this->oTemplate = $oTemplate;
App()->clientScript->registerScript('sLSJavascriptVar', $sLSJavascriptVar, CClientScript::POS_HEAD);
App()->clientScript->registerScript('setJsVar', "setJsVar();", CClientScript::POS_BEGIN);
// Ensure all js var is set before rendering the page (User can click before $.ready)
foreach ($oTemplate->packages as $package) {
App()->getClientScript()->registerPackage($package);
}
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js");
if ($oTemplate->cssFramework == 'bootstrap') {
App()->bootstrap->register();
}
useFirebug();
ob_start(function ($buffer, $phase) {
App()->getClientScript()->render($buffer);
App()->getClientScript()->reset();
return $buffer;
});
ob_implicit_flush(false);
$this->action();
ob_flush();
}
示例8: actionIndex
/**
* 模板列表
* @author yongze
*/
public function actionIndex($id)
{
$dsModel = $this->loadModel((int) $id, 'ds');
$dbModel = $this->loadModel((int) $dsModel->database_id, 'db');
$model = Template::model();
$attr = $model->attributeLabels();
$model->dataset_id = (int) $id;
$data['attr'] = $attr;
//模型属性
$data['model'] = $model;
$data['dbModel'] = $dbModel;
$data['dsModel'] = $dsModel;
$data['datasetId'] = $dsModel->id;
$data['info'] = $this->promptInfo();
$this->render('index', $data);
}
示例9: eventDelete
public function eventDelete($event)
{
switch ($event->objectUsed) {
case 'Account':
Template::model()->dbConnection->createCommand("DELETE FROM TemplateRowAccount WHERE accountId={$event->id}")->execute();
break;
case 'Company':
$templateList = Template::model()->findAll('companyId=:companyId', array(':companyId' => $event->id));
if ($templateList != null) {
foreach ($templateList as $model) {
$model->delete();
}
}
break;
}
}
示例10: _renderHtml
/**
* Render stuff
*
* @param string $html
* @param array $aSurveyInfo
* @param int $iSurveyID
* @return void
*/
private function _renderHtml($html, $aSurveyInfo, $iSurveyID)
{
sendCacheHeaders();
doHeader();
$aSupportData = array('thissurvey' => $aSurveyInfo);
$oTemplate = Template::model()->getInstance(null, $iSurveyID);
if ($oTemplate->cssFramework == 'bootstrap') {
App()->bootstrap->register();
}
$thistpl = $oTemplate->viewPath;
echo templatereplace(file_get_contents($thistpl . 'startpage.pstpl'), array(), $aSupportData);
$aData['html'] = $html;
$aData['thistpl'] = $thistpl;
$this->render('/opt_view', $aData);
echo templatereplace(file_get_contents($thistpl . 'endpage.pstpl'), array(), $aSupportData);
doFooter();
}
示例11: actionPublicList
public function actionPublicList($lang = null)
{
if (!empty($lang)) {
App()->setLanguage($lang);
} else {
App()->setLanguage(App()->getConfig('defaultlang'));
}
$oTemplate = Template::model()->getInstance(Yii::app()->getConfig("defaulttemplate"));
if ($oTemplate->cssFramework == 'bootstrap') {
// We now use the bootstrap package isntead of the Yiistrap TbApi::register() method
// Then instead of using the composer dependency system for templates
// We can use the package dependency system
Yii::app()->getClientScript()->registerMetaTag('width=device-width, initial-scale=1.0', 'viewport');
App()->bootstrap->registerAllScripts();
}
$this->render('publicSurveyList', array('publicSurveys' => Survey::model()->active()->open()->public()->with('languagesettings')->findAll(), 'futureSurveys' => Survey::model()->active()->registration()->public()->with('languagesettings')->findAll()));
}
示例12: actionForm
public function actionForm($id = null, $template_type_id = null)
{
if (Yii::app()->session["username"] != null) {
$this->layout = "main";
} else {
$this->layout = "front";
}
$model = new Template();
if (!empty($_POST["Template"])) {
// 1.step new user
$model = new Template();
// 2.step edit template
if (!empty($id)) {
$model = Template::model()->findByPk($id);
}
// 3. step merge data
$model->_attributes = $_POST["Template"];
$model->template_type_id = $template_type_id;
$model->created = new CDbExpression('NOW()');
$model->image = CUploadedFile::getInstance($model, 'image');
$fecha = date('YmdHms');
if ($model->image) {
$attach_src = Yii::app()->basePath . '/../docs/' . $fecha . '.' . $model->image->getExtensionName();
//. '_' . $model->$imageAttrName;
$model->image->saveAs($attach_src);
$model->image = $fecha . '.' . $model->image->getExtensionName();
// . '_' . $model->$imageAttrName;
}
// 5. step save/update
if ($model->save()) {
$this->redirect("index.php?r=template&template_type_id={$template_type_id}");
}
}
if (!empty($id)) {
$model = Template::model()->findByPk($id);
}
$this->render("//template/form", array("model" => $model, "template_type_id" => $template_type_id));
}
示例13: run
function run($args)
{
extract($args);
$redata = compact(array_keys(get_defined_vars()));
$sTemplatePath = $_SESSION['survey_' . $surveyid]['templatepath'];
sendCacheHeaders();
doHeader();
$oTemplate = Template::model()->getInstance(null, $surveyid);
echo templatereplace(file_get_contents($oTemplate->viewPath . "startpage.pstpl"), array(), $redata);
echo "\n\n<!-- JAVASCRIPT FOR CONDITIONAL QUESTIONS -->\n" . "\t<script type='text/javascript'>\n" . "function checkconditions(value, name, type, evt_type)\n" . "\t{\n" . "\t}\n" . "\t</script>\n\n";
echo CHtml::form(array("/survey/index", "sid" => $surveyid), 'post') . "\n";
echo templatereplace(file_get_contents($oTemplate->viewPath . "load.pstpl"), array(), $redata);
//PRESENT OPTIONS SCREEN (Replace with Template Later)
//END
echo "<input type='hidden' name='loadall' value='reload' />\n";
if (isset($clienttoken) && $clienttoken != "") {
echo "<input type='hidden' name='token' value='{$clienttoken}' />\n";
}
echo "</form>";
echo templatereplace(file_get_contents($oTemplate->viewPath . "endpage.pstpl"), array(), $redata);
doFooter();
exit;
}
示例14: templatereplace
//.........这里部分代码省略.........
$saved_id = Yii::app()->session['survey_' . $_surveyid]['srid'];
}
Yii::app()->loadHelper('surveytranslator');
if (isset($thissurvey['sid'])) {
$surveyid = $thissurvey['sid'];
}
// lets sanitize the survey template
if (isset($thissurvey['templatedir'])) {
$templatename = $thissurvey['templatedir'];
} else {
$templatename = Yii::app()->getConfig('defaulttemplate');
}
if (!isset($templatedir)) {
$templatedir = getTemplatePath($templatename);
}
if (!isset($templateurl)) {
$templateurl = getTemplateURL($templatename) . "/";
}
if (!$anonymized && isset($thissurvey['anonymized'])) {
$anonymized = $thissurvey['anonymized'] == "Y";
}
// TEMPLATECSS
$_templatecss = "";
$_templatejs = "";
/**
* Template css/js files from the template config files are loaded.
* It use the asset manager (so user never need to empty the cache, even if template is updated)
* If debug mode is on, no asset manager is used.
*
* oTemplate is defined in controller/survey/index
*
* If templatereplace is called from the template editor, a $oTemplate is provided.
*/
$oTemplate = Template::model()->getInstance($templatename);
$aCssFiles = $oTemplate->config->files->css->filename;
$aJsFiles = $oTemplate->config->files->js->filename;
$aOtherFiles = $oTemplate->otherFiles;
//var_dump($aOtherFiles); die();
if (stripos($line, "{TEMPLATECSS}")) {
// If the template has files for css, we can't publish the files one by one, but we must publish them as a whole directory
// TODO : extend asset manager so it check for file modification even in directory mode
if (!YII_DEBUG || count($aOtherFiles) < 0) {
foreach ($aCssFiles as $sCssFile) {
if (file_exists($oTemplate->path . DIRECTORY_SEPARATOR . $sCssFile)) {
Yii::app()->getClientScript()->registerCssFile(App()->getAssetManager()->publish($oTemplate->path . DIRECTORY_SEPARATOR . $sCssFile), $sCssFile['media']);
}
}
} else {
foreach ($aCssFiles as $sCssFile) {
if (file_exists($oTemplate->path . DIRECTORY_SEPARATOR . $sCssFile)) {
Yii::app()->getClientScript()->registerCssFile("{$templateurl}{$sCssFile}", $sCssFile['media']);
}
}
}
/* RTL CSS */
if (getLanguageRTL(App()->language)) {
$aCssFiles = (array) $oTemplate->config->files->rtl->css->filename;
if (!YII_DEBUG) {
foreach ($aCssFiles as $sCssFile) {
if (file_exists($oTemplate->path . DIRECTORY_SEPARATOR . $sCssFile)) {
Yii::app()->getClientScript()->registerCssFile(App()->getAssetManager()->publish($oTemplate->path . DIRECTORY_SEPARATOR . $sCssFile), $sCssFile['media']);
}
}
} else {
foreach ($aCssFiles as $sCssFile) {
if (file_exists($oTemplate->path . DIRECTORY_SEPARATOR . $sCssFile)) {
示例15: getQuestionReplacement
/**
* Construction of replacement array, actually doing it with redata
*
* @param $aQuestionQanda : array from qanda helper
* @return aray of replacement for question.psptl
**/
public static function getQuestionReplacement($aQuestionQanda)
{
// Get the default replacement and set empty value by default
$aReplacement = array("QID" => "", "SGQ" => "", "AID" => "", "QUESTION_CODE" => "", "QUESTION_NUMBER" => "", "QUESTION" => "", "QUESTION_TEXT" => "", "QUESTIONHELP" => "", "QUESTIONHELPPLAINTEXT" => "", "QUESTION_CLASS" => "", "QUESTION_MAN_CLASS" => "", "QUESTION_INPUT_ERROR_CLASS" => "", "ANSWER" => "", "QUESTION_HELP" => "", "QUESTION_VALID_MESSAGE" => "", "QUESTION_FILE_VALID_MESSAGE" => "", "QUESTION_MAN_MESSAGE" => "", "QUESTION_MANDATORY" => "", "QUESTION_ESSENTIALS" => "");
if (!is_array($aQuestionQanda) || empty($aQuestionQanda[0])) {
return $aReplacement;
}
$iQid = $aQuestionQanda[4];
$lemQuestionInfo = LimeExpressionManager::GetQuestionStatus($iQid);
$iSurveyId = Yii::app()->getConfig('surveyID');
// Or : by SGQA of question ? by Question::model($iQid)->sid;
$oSurveyId = Survey::model()->findByPk($iSurveyId);
$sType = $lemQuestionInfo['info']['type'];
// Core value : not replaced
$aReplacement['QID'] = $iQid;
$aReplacement['GID'] = $aQuestionQanda[6];
// Not sure for aleatory : it's the real gid or the updated gid ? We need original gid or updated gid ?
$aReplacement['SGQ'] = $aQuestionQanda[7];
$aReplacement['AID'] = isset($aQuestionQanda[0]['aid']) ? $aQuestionQanda[0]['aid'] : "";
$aReplacement['QUESTION_CODE'] = $aReplacement['QUESTION_NUMBER'] = "";
$sCode = $aQuestionQanda[5];
$iNumber = $aQuestionQanda[0]['number'];
switch (Yii::app()->getConfig('showqnumcode')) {
case 'both':
$aReplacement['QUESTION_CODE'] = $sCode;
$aReplacement['QUESTION_NUMBER'] = $iNumber;
break;
case 'number':
$aReplacement['QUESTION_NUMBER'] = $iNumber;
break;
case 'number':
$aReplacement['QUESTION_CODE'] = $sCode;
break;
case 'choose':
default:
switch ($oSurveyId->showqnumcode) {
case 'B':
// Both
$aReplacement['QUESTION_CODE'] = $sCode;
$aReplacement['QUESTION_NUMBER'] = $iNumber;
break;
case 'N':
$aReplacement['QUESTION_NUMBER'] = $iNumber;
break;
case 'C':
$aReplacement['QUESTION_CODE'] = $sCode;
break;
case 'X':
default:
break;
}
break;
}
$aReplacement['QUESTION'] = $aQuestionQanda[0]['all'];
// Deprecated : only used in old template (very old)
// Core value : user text
$aReplacement['QUESTION_TEXT'] = $aQuestionQanda[0]['text'];
$aReplacement['QUESTIONHELP'] = $lemQuestionInfo['info']['help'];
// User help
// To be moved in a extra plugin : QUESTIONHELP img adding
$sTemplateDir = Template::model()->getTemplatePath($oSurveyId->template);
$sTemplateUrl = Template::model()->getTemplateURL($oSurveyId->template);
if (flattenText($aReplacement['QUESTIONHELP'], true, true) != '') {
$aReplacement['QUESTIONHELP'] = Yii::app()->getController()->renderPartial('/survey/system/questionhelp/questionhelp', array('questionHelp' => $aReplacement['QUESTIONHELP']), true);
}
// Core value :the classes
$aReplacement['QUESTION_CLASS'] = Question::getQuestionClass($sType);
//get additional question classes from question attribute
$aQuestionAttributes = getQuestionAttributeValues($aQuestionQanda[4]);
//add additional classes
if (isset($aQuestionAttributes['cssclass'])) {
$aReplacement['QUESTION_CLASS'] .= " " . $aQuestionAttributes['cssclass'];
}
$aMandatoryClass = array();
if ($lemQuestionInfo['info']['mandatory'] == 'Y') {
$aMandatoryClass[] = 'mandatory';
}
if ($lemQuestionInfo['anyUnanswered'] && $_SESSION['survey_' . $iSurveyId]['maxstep'] != $_SESSION['survey_' . $iSurveyId]['step']) {
$aMandatoryClass[] = 'missing';
}
$aReplacement['QUESTION_MAN_CLASS'] = !empty($aMandatoryClass) ? " " . implode(" ", $aMandatoryClass) : "";
$aReplacement['QUESTION_INPUT_ERROR_CLASS'] = $aQuestionQanda[0]['input_error_class'];
// Core value : LS text : EM and not
$aReplacement['ANSWER'] = $aQuestionQanda[1];
$aReplacement['QUESTION_HELP'] = $aQuestionQanda[0]['help'];
// Core help only, not EM
$aReplacement['QUESTION_VALID_MESSAGE'] = $aQuestionQanda[0]['valid_message'];
// $lemQuestionInfo['validTip']
$aReplacement['QUESTION_FILE_VALID_MESSAGE'] = $aQuestionQanda[0]['file_valid_message'];
// $lemQuestionInfo['??']
$aReplacement['QUESTION_MAN_MESSAGE'] = $aQuestionQanda[0]['man_message'];
$aReplacement['QUESTION_MANDATORY'] = $aQuestionQanda[0]['mandatory'];
// For QUESTION_ESSENTIALS
$aHtmlOptions = array();
//.........这里部分代码省略.........