Created
November 21, 2010 17:39
-
-
Save thiagosf/708942 to your computer and use it in GitHub Desktop.
Arquivo de erro para facilitar na criação de arquivos de template para CakePHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2><?php __('Missing View'); ?></h2> | |
<p class="error"> | |
<strong><?php __('Error'); ?>: </strong> | |
<?php printf(__('The view for %1$s%2$s was not found.', true), '<em>' . $controller . 'Controller::</em>', '<em>' . $action . '()</em>'); ?> | |
</p> | |
<p class="error"> | |
<strong><?php __('Error'); ?>: </strong> | |
<?php printf(__('Confirm you have created the file: %s', true), $file); ?> | |
</p> | |
<p class="notice"> | |
<strong><?php __('Notice'); ?>: </strong> | |
<?php printf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_view.ctp'); ?> | |
</p> | |
<?php | |
// Criando arquivo autmaticamente | |
if (isset($_GET['auto'])) { | |
$dir = '..' . DS . 'views' . DS . Inflector::underscore($controller); | |
if (!is_dir($dir)) mkdir($dir); | |
$name = $dir . DS . $action . '.ctp'; | |
// Forca UTF-8 | |
$valor = "Arquivo criado com sucessó: ".$name; | |
if (!is_file($name)) { | |
$fp = fopen($name, 'a'); | |
fwrite($fp, utf8_encode($valor)); | |
fclose($fp); | |
echo '<p><a href="">Arquivo criado com sucesso!</a></p>'; | |
} | |
} | |
else { | |
$name = '..' . DS . 'views' . DS . Inflector::underscore($controller) . DS . $action . '.ctp'; | |
if (!is_file($name)) { | |
echo '<p><a href="?auto=true">Criar aquivo</a></p>'; | |
} | |
} | |
// Fim da criação do arquivo | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment