FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


cakePHP





geekbackpacker
according to
Code:

<?php
if (!Configure::read('debug')):
   throw new NotFoundException();
endif;
App::uses('Debugger', 'Utility');
?>
<h2><?php echo __d('', 'Release Notes for CakePHP %s.', Configure::version()); ?></h2>
<p>
   <a href="http://cakephp.org/changelogs/<?php echo Configure::version(); ?>"><?php echo __d('', 'Read the changelog'); ?> </a>
</p>
<?php
if (Configure::read('debug') > 0):
   Debugger::checkSecurityKeys();
endif;
?>
<?php
   if (version_compare(PHP_VERSION, '5.2.8', '>=')):
      echo '<span class="notice success">';
         echo __d('cake_dev', 'Your version of PHP is 5.2.8 or higher.');
      echo '</span>';
   else:
      echo '<span class="notice">';
         echo __d('cake_dev', 'Your version of PHP is too low. You need PHP 5.2.8 or higher to use CakePHP.');
      echo '</span>';
   endif;
?>
</p>
<p>
   <?php
      if (is_writable(TMP)):
         echo '<span class="notice success">';
            echo __d('cake_dev', 'Your tmp directory is writable.');
         echo '</span>';
      else:
         echo '<span class="notice">';
            echo __d('cake_dev', 'Your tmp directory is NOT writable.');
         echo '</span>';
      endif;
   ?>
</p>
<p>
   <?php
      $settings = Cache::settings();
      if (!empty($settings)):
         echo '<span class="notice success">';
            echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit APP/Config/core.php ', '<em>'. $settings['engine'] . 'Engine</em>');
         echo '</span>';
      else:
         echo '<span class="notice">';
            echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in APP/Config/core.php');
         echo '</span>';
      endif;
   ?>
</p>
<p>
   <?php
      $filePresent = null;
      if (file_exists(APP . 'Config' . DS . 'database.php')):
         echo '<span class="notice success">';
            echo __d('cake_dev', 'Your database configuration file is present.');
            $filePresent = true;
         echo '</span>';
      else:
         echo '<span class="notice">';
            echo __d('cake_dev', 'Your database configuration file is NOT present.');
            echo '<br/>';
            echo __d('cake_dev', 'Rename APP/Config/database.php.default to APP/Config/database.php');
         echo '</span>';
      endif;
   ?>
</p>
<?php
if (isset($filePresent)):
   App::uses('ConnectionManager', 'Model');
   try {
      $connected = ConnectionManager::getDataSource('default');
   } catch (Exception $connectionError) {
      $connected = false;
      $errorMsg = $connectionError->getMessage();
      if (method_exists($connectionError, 'getAttributes')) {
         $attributes = $connectionError->getAttributes();
         if (isset($errorMsg['message'])) {
            $errorMsg .= '<br />' . $attributes['message'];
         }
      }
   }
?>
<p>
   <?php
      if ($connected && $connected->isConnected()):
         echo '<span class="notice success">';
             echo __d('cake_dev', 'Cake is able to connect to the database.');
         echo '</span>';
      else:
         echo '<span class="notice">';
            echo __d('cake_dev', 'Cake is NOT able to connect to the database.');
            echo '<br /><br />';
            echo $errorMsg;
         echo '</span>';
      endif;
   ?>
</p>
<?php endif; ?>
<?php
   App::uses('Validation', 'Utility');
   if (!Validation::alphaNumeric('cakephp')) {
      echo '<p><span class="notice">';
         echo __d('cake_dev', 'PCRE has not been compiled with Unicode support.');
         echo '<br/>';
         echo __d('cake_dev', 'Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring');
      echo '</span></p>';
   }
?>

<p>
   <?php
      if (CakePlugin::loaded('DebugKit')):
         echo '<span class="notice success">';
            echo __d('cake_dev', 'DebugKit plugin is present');
         echo '</span>';
      else:
         echo '<span class="notice">';
            echo __d('cake_dev', 'DebugKit is not installed. It will help you inspect and debug different aspects of your application.');
            echo '<br/>';
            echo __d('cake_dev', 'You can install it from %s', $this->Html->link('github', 'https://github.com/cakephp/debug_kit'));
         echo '</span>';
      endif;
   ?>
</p>

<h3><?php echo __d('cake_dev', 'Editing this Page'); ?></h3>
<p>
</p>

<h3><?php echo __d('cake_dev', 'Getting Started'); ?></h3>
<p>
   <?php
      echo $this->Html->link(
         sprintf('<strong>%s</strong> %s', __d('cake_dev', 'New'), __d('cake_dev', 'CakePHP 2.0 Docs')),
         'http://book.cakephp.org/2.0/en/',
         array('target' => '_blank', 'escape' => false)
      );
   ?>
</p>
<p>
<ul>
   <li>
      <?php echo $this->Html->link('DebugKit', 'https://github.com/cakephp/debug_kit') ?>:
      <?php echo __d('cake_dev', 'provides a debugging toolbar and enhanced debugging tools for CakePHP applications.'); ?>
   </li>
   <li>
      <?php echo $this->Html->link('Localized', 'https://github.com/cakephp/localized') ?>:
      <?php echo __d('cake_dev', 'contains various localized validation classes and translations for specific countries'); ?>
   </li>
</ul>
</p>



<h3><?php echo __d('cake_dev', 'More about Cake'); ?></h3>
<p>
<?php echo __d('cake_dev', 'CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC.'); ?>
</p>
<p>
<?php echo __d('cake_dev', 'Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.'); ?>
</p>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>





i dont know
Code:
<?php echo __d('', 'Release Notes for CakePHP %s.', Configure::version()); ?>
what is %s and where is it come from?
Peterssidan
I don't know anything about CakePHP but I guess __d works similar to functions like sprintf.

Code:
$str1 = 'James';
$str2 = 'Greg';
sprintf('hello %s!', $str1); // Returns 'hello James!'
sprintf('%s and %s are my friends.', $str1, $str2); // Returns 'James and Greg are my friends.'
geekbackpacker
Peterssidan wrote:
I don't know anything about CakePHP but I guess __d works similar to functions like sprintf.

Code:
$str1 = 'James';
$str2 = 'Greg';
sprintf('hello %s!', $str1); // Returns 'hello James!'
sprintf('%s and %s are my friends.', $str1, $str2); // Returns 'James and Greg are my friends.'


i am asking about %s

read http://api.cakephp.org/2.2/function-__d.html and do not guess
Peterssidan
Well that page doesn't say anything how %s is treaded. I think my guess was pretty good, but if you want to be sure why not look in the CakePHP code itself?
geekbackpacker
Peterssidan wrote:
Well that page doesn't say anything how %s is treaded. I think my guess was pretty good, but if you want to be sure why not look in the CakePHP code itself?

Laughing
this is CakePHP back-end source code.


i do not know %s


Quote:
MODERATOR - Long strings of emoticons removed
I suggest you read through:
.: The Forum Rules
.: The Frihost hosting FAQ
.: Quick Frihost guide
-Ankhanu
Peterssidan
Ok, here is the code.
Code:
/**
 * Allows you to override the current domain for a single message lookup.
 *
 * @param string $domain Domain
 * @param string $msg String to translate
 * @param mixed $args Array with arguments or multiple arguments in function
 * @return translated string
 * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__d
 */
function __d($domain, $msg, $args = null) {
   if (!$msg) {
      return;
   }
   App::uses('I18n', 'I18n');
   $translated = I18n::translate($msg, null, $domain);
   if ($args === null) {
      return $translated;
   } elseif (!is_array($args)) {
      $args = array_slice(func_get_args(), 2);
   }
   return vsprintf($translated, $args);
}

It uses vsprintf which uses the same format as sprintf so I was right. I recommend you read the PHP sprintf documentation (at least the examples) to learn more about the format.
geekbackpacker
Peterssidan wrote:
Ok, here is the code.
Code:
/**
 * Allows you to override the current domain for a single message lookup.
 *
 * @param string $domain Domain
 * @param string $msg String to translate
 * @param mixed $args Array with arguments or multiple arguments in function
 * @return translated string
 * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__d
 */
function __d($domain, $msg, $args = null) {
   if (!$msg) {
      return;
   }
   App::uses('I18n', 'I18n');
   $translated = I18n::translate($msg, null, $domain);
   if ($args === null) {
      return $translated;
   } elseif (!is_array($args)) {
      $args = array_slice(func_get_args(), 2);
   }
   return vsprintf($translated, $args);
}

It uses vsprintf which uses the same format as sprintf so I was right. I recommend you read the PHP sprintf documentation (at least the examples) to learn more about the format.
Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing Laughing

Code:
<?php echo __d('', 'Release Notes for CakePHP %s.', Configure::version()); ?>
shorter
Code:
('', 'Release Notes for CakePHP %s.', Configure::version())
notice
Code:
%s




how is yo answer related to %s.

you try to say echo_d bla bla bla

Laughing



Quote:
MODERATOR - Long strings of emoticons removed
I suggest you read through:
.: The Forum Rules
.: The Frihost hosting FAQ
.: Quick Frihost guide
-Ankhanu
Peterssidan
%s are simply two characters in the string. Nothing special about them. Some functions (sprinf, __d, etc.) parse the string and handles %s in a special way, so that is why the function is relevant.

What I have been trying to say is that __d handles %s the same way as sprintf does so by looking at the sprintf documentation and examples you should be able to get an understanding of how it works.

In your example %s will be substituted by whatever is returned by Configure::version().
Code:
__d('', 'Release Notes for CakePHP %s.', Configure::version());

If Configure::version() returns "10" the above function call would give the same result as
Code:
__d('', 'Release Notes for CakePHP 10.');
Related topics
Wasze Strony
how did you learn about html, php or other languages???
What is a good php mvc framework
CakePHP
PHP Rapid Application Development
PHP Framework << please sticky this post
Best framework?
PHP and Mysql Project. Help
Choosing PHP web framework for intranet
Web Layer and Application Layer
Which php version on the new server? (5.2.12 or 5.3.1)
Email to PHP
javascript framework vs php framework
CakePHP
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.