デバッグバー用のTwigを初期化する

@return  void
163874
private function initTwig(){
        if($this->twig === null){
            $this->twig = new Environment(
                new FilesystemLoader(__DIR__ . "/../resource/views"),
                [
                    "debug" => true,
                ]
            );

            $this->twig->addExtension(
                new \Twig\Extension\DebugExtension
            );
            $this->twig->addExtension(
                new \Twig\Extension\StringLoaderExtension
            );
            $this->twig->addFilter(new \Twig_Filter("md5", function($v){
                return md5($v);
            }));
        }
    }
609632
public function onDeleteTemplates()
    {
        $this->validateRequestTheme();

        $type = Request::input('type');
        $templates = Request::input('template');
        $error = null;
        $deleted = [];

        try {
            foreach ($templates as $path => $selected) {
                if ($selected) {
                    $this->loadTemplate($type, $path)->delete();
                    $deleted[] = $path;
                }
            }
        }
        catch (Exception $ex) {
            $error = $ex->getMessage();
        }

        /**
         * @event cms.template.delete
         * Fires after a CMS template (page|partial|layout|content|asset) has been deleted.
         *
         * Example usage:
         *
         *     Event::listen('cms.template.delete', function ((\Cms\Controllers\Index) $controller, (string) $type) {
         *         \Log::info("A $type has been deleted");
         *     });
         *
         * Or
         *
         *     $CmsIndexController->bindEvent('template.delete', function ((string) $type) {
         *         \Log::info("A $type has been deleted");
         *     });
         *
         */
        $this->fireSystemEvent('cms.template.delete', [$type]);

        return [
            'deleted' => $deleted,
            'error'   => $error,
            'theme'   => Request::input('theme')
        ];
    }
31889
public function renderView()
    {
        if ($this->path) {
            $this->js(true)->tab(
                ['cache' => false, 'auto' => true, 'path' => $this->path, 'apiSettings' => ['data' => ['__atk_tab' => 1]]]
            );
        } else {
            $this->js(true)->tab();
        }

        if ($this->owner->activeTabName == $this->name) {
            $this->js(true)->click();
        }

        parent::renderView();
    }
1269069
public function run() {
		
		echo CHtml::openTag('div', $this->htmlOptions);

		foreach ($this->buttons as $button) {
			if (isset($button['visible']) && $button['visible'] === false) {
				continue;
			}
			
			$validToggles = array(self::TOGGLE_CHECKBOX, self::TOGGLE_RADIO);
			if (isset($this->toggle) && in_array($this->toggle, $validToggles)) {
				$this->buttonType = $this->toggle;
			}
			
			$justifiedNotLink = $this->justified && $this->buttonType !== TbButton::BUTTON_LINK;
			if($justifiedNotLink)
				echo '<div class="btn-group">';
			
			$this->controller->widget(
				'booster.widgets.TbButton',
				array(
					'buttonType' => isset($button['buttonType']) ? $button['buttonType'] : $this->buttonType,
					'context' => isset($button['context']) ? $button['context'] : $this->context,
					'size' => $this->size, // all buttons in a group cannot vary in size
					'icon' => isset($button['icon']) ? $button['icon'] : null,
					'label' => isset($button['label']) ? $button['label'] : null,
					'url' => isset($button['url']) ? $button['url'] : null,
					'active' => isset($button['active']) ? $button['active'] : false,
					'disabled' => isset($button['disabled']) ? $button['disabled'] : false,
					'items' => isset($button['items']) ? $button['items'] : array(),
					'ajaxOptions' => isset($button['ajaxOptions']) ? $button['ajaxOptions'] : array(),
					'htmlOptions' => isset($button['htmlOptions']) ? $button['htmlOptions'] : array(),
					'dropdownOptions' => isset($button['dropdownOptions']) ? $button['dropdownOptions'] : array(),
					'encodeLabel' => isset($button['encodeLabel']) ? $button['encodeLabel'] : $this->encodeLabel,
                    'tooltip' => isset($button['tooltip']) ? $button['tooltip'] : false,
                    'tooltipOptions' => isset($button['tooltipOptions']) ? $button['tooltipOptions'] : array(),
				)
			);
			
			if($justifiedNotLink)
				echo '</div>';
		}
		echo '</div>';
	}
1012491
public function actionTemplates()
    {
        $foundTemplates = $this->findTemplatesFiles();

        if (!$foundTemplates) {
            $this->notifyNoTemplatesFound();
        } else {
            $this->notifyTemplatesCanBeGenerated($foundTemplates);
        }
    }
517334
private function addDebugInfo(): void
    {
        $tpl = $this->getTplPath($this->widget->template);

        $this->html = "<span title='WidgetObj : ".get_class($this->widget).".php&#013;Template : {$tpl}{$this->cacheState()}'>{$this->html}</span>";
    }
722353
public function run()
    {
        if (!isset($this->parts['{visible}'])) {
            $this->renderVisible();
        }
        if (!isset($this->parts['{button}'])) {
            $this->renderSpoiled();
        }
        if (!isset($this->parts['{hidden}'])) {
            $this->renderHidden();
        }

        echo strtr($this->template, $this->parts);
    }
555549
protected function InitForm()
    {
        $this->block = $this->LoadElement();
        $this->AddTagNameField();
        $this->AddCssClassField();
        $this->AddCssIDField();
        $this->AddSubmit();
    }
349486
private function load(): void
	{
		// Skip if it's already loaded
		if ($this->state === self::STATE_LOADED) return;

		// Attach parameters (only if we have some)
		if ($this->parameters !== []) {
			// Attach parameters to form
			$this['parametersForm']->setDefaults($this->parameters);

			// Attach parameters to subreport
			$this->subreport->attach($this->parameters);
		}

		// Compile (fetch data)
		$this->subreport->compile();

		// Preprocess (only if it is not already)
		if (!$this->subreport->isState(Subreport::STATE_PREPROCESSED)) {
			$this->subreport->preprocess();
		}

		// Change inner state
		$this->state = self::STATE_LOADED;
	}
246474
public function render()
    {
        $this->getWpBridge()->addFilter('timber_post_getter_get_posts', [$this, 'addWpBridgeToPosts'], 10, 3);

        $context   = $this->getContext();
        $templates = $this->getTemplates();

        $this->validateTemplates($templates);
        $this->validateContext($context);

        $this->getTimberBridge()->render(
            $templates,
            array_merge($this->getTimberBridge()->getContext(), $context),
            ($this->getCacheExpiresSeconds() ?: false), // False disables cache altogether.
            $this->getCacheMode()
        );
    }
1108112
public function registerTwig()
    {
        \Twig_Autoloader::register();

        $loader = new \Twig_Loader_Filesystem($_SERVER['DOCUMENT_ROOT'].'/../src/' . $this->app->getProjectName() . '/View');

        $twig = new \Twig_Environment($loader, array(
            'cache'       => $_SERVER['DOCUMENT_ROOT'].'/../app/cache/twig',
            'auto_reload' => true
        ));

        return $twig;
    }
526701
private function copyTemplates()
    {
        $dirPath = $this->bundle->getPath();
        $this->filesystem->copy($this->skeletonDir . '/Resources/views/Pages/FormPage/view.html.twig', $dirPath . '/Resources/views/Pages/'.$this->entity.'/view.html.twig', true);
        $this->filesystem->copy($this->skeletonDir . '/Resources/views/Pages/FormPage/pagetemplate.html.twig', $dirPath . '/Resources/views/Pages/'.$this->entity.'/pagetemplate.html.twig', true);
        GeneratorUtils::replace('~~~BUNDLE~~~', $this->bundle->getName(), $dirPath . '/Resources/views/Pages/'.$this->entity.'/pagetemplate.html.twig');

        GeneratorUtils::prepend("{% extends '" . $this->bundle->getName() .":Page:layout.html.twig' %}\n", $dirPath . '/Resources/views/Pages/'.$this->entity.'/view.html.twig');
    }
1321519
public function initTemplateTags()
    {
        if ($this->template
            && $this->app->hasMethod('setTags')
        ) {
            /** @type App_Web $this->app */
            $this->app->setTags($this->template);
        }
    }
299139
public function actionEdit() 
	{
		$model = OmmuMeta::model()->findByPk(1);
		if($model == null)
			$model=new OmmuMeta;

		// Uncomment the following line if AJAX validation is needed
		$this->performAjaxValidation($model);

		if(isset($_POST['OmmuMeta'])) {
			$model->attributes=$_POST['OmmuMeta'];
			$model->scenario = 'setting';
			
			if($model->save()) {
				Yii::app()->user->setFlash('success', Yii::t('phrase', 'Global Meta success updated.'));
				$this->redirect(array('edit'));
			}
		}

		$this->pageTitle = Yii::t('phrase', 'Meta Settings');
		$this->pageDescription = '';
		$this->pageMeta = '';
		$this->render('admin_edit', array(
			'model'=>$model,
		));
	}
1010043
protected function preProcess(): void
    {
        Router::process();

        // disable Layout for XmlHttpRequests
        if (Request::isXmlHttpRequest()) {
            $this->layoutFlag = false;
        }

        // switch to JSON response based on Accept header
        if (Request::checkAccept([Request::TYPE_HTML, Request::TYPE_JSON]) === Request::TYPE_JSON) {
            $this->layoutFlag = false;
            Response::setType('JSON');
        }
    }
735619
public function actionEdit() 
	{
		$category=new BannerCategory('search');
		$category->unsetAttributes();	// clear any default values
		if(Yii::app()->getRequest()->getParam('BannerCategory')) {
			$category->attributes=Yii::app()->getRequest()->getParam('BannerCategory');
		}

		$columns = $category->getGridColumn($this->gridColumnTemp());
		
		$model = BannerSetting::model()->findByPk(1);
		if($model == null)
			$model=new BannerSetting;

		// Uncomment the following line if AJAX validation is needed
		$this->performAjaxValidation($model);

		if(isset($_POST['BannerSetting'])) {
			$model->attributes=$_POST['BannerSetting'];

			$jsonError = CActiveForm::validate($model);
			if(strlen($jsonError) > 2) {
				$errors = $model->getErrors();
				$summary['msg'] = "<div class='errorSummary'><strong>".Yii::t('phrase', 'Please fix the following input errors:')."</strong>";
				$summary['msg'] .= "<ul>";
				foreach($errors as $key => $value) {
					$summary['msg'] .= "<li>{$value[0]}</li>";
				}
				$summary['msg'] .= "</ul></div>";

				$message = json_decode($jsonError, true);
				$merge = array_merge_recursive($summary, $message);
				$encode = json_encode($merge);
				echo $encode;

			} else {
				if(Yii::app()->getRequest()->getParam('enablesave') == 1) {
					if($model->save()) {
						echo CJSON::encode(array(
							'type' => 0,
							'msg' => '<div class="errorSummary success"><strong>'.Yii::t('phrase', 'Banner setting success updated.').'</strong></div>',
						));
						/*
						Yii::app()->user->setFlash('success', Yii::t('phrase', 'Banner setting success updated.'));
						$this->redirect(array('edit'));
						*/
					} else
						print_r($model->getErrors());
				}
			}
			Yii::app()->end();
		}

		$this->pageTitle = Yii::t('phrase', 'Banner Settings');
		$this->pageDescription = '';
		$this->pageMeta = '';
		$this->render('admin_edit', array(
			'model'=>$model,
			'category'=>$category,
			'columns' => $columns,
		));
	}
731777
private function scanTwigFiles()
    {
        $finder = new Finder();
        $finder->files()
            ->ignoreVCS(true)
            ->name('*.twig')
            ->notName('*~')
            ->exclude(['cache', 'config', 'database', 'resources', 'tests', 'bower_components', 'node_modules'])
            ->in($this->app['path_resolver']->resolve('themes'))
            ->in($this->app['path_resolver']->resolve('app')); // yes, app = bad. Will be refactored in 3.4

        // Regex from: stackoverflow.com/questions/5695240/php-regex-to-ignore-escaped-quotes-within-quotes
        $twigRegex = [
            "/\b__\(\s*'([^'\\\\]*(?:\\\\.[^'\\\\]*)*)'(?U).*\)/s" => ['\\\'' => '\''], // __('single_quoted_string'…
            '/\b__\(\s*"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"(?U).*\)/s' => ['\"'   => '"'], // __("double_quoted_string"…
        ];

        foreach ($finder as $file) {
            /** @var \Symfony\Component\Finder\SplFileInfo $file */
            foreach ($twigRegex as $regex => $stripslashes) {
                if (preg_match_all($regex, $file->getContents(), $matches)) {
                    foreach ($matches[1] as $foundString) {
                        $this->addTranslatable(strtr($foundString, $stripslashes));
                    }
                }
            }
        }
    }