Skip to content

Commit

Permalink
Remove more <?php blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Nov 20, 2012
1 parent 60ba09d commit f75866c
Show file tree
Hide file tree
Showing 60 changed files with 26 additions and 614 deletions.
2 changes: 1 addition & 1 deletion en/appendices/cakephp-development-process.rst
Expand Up @@ -53,4 +53,4 @@ on irc.freenode.net.

.. meta::
:title lang=en: CakePHP Development Process
:keywords lang=en: maintenance branch,community interaction,community feature,necessary feature,stable release,ticket system,advanced feature,power users,feature set,chat irc,leading edge,router,new features,members,attempt,development branches,branch development
:keywords lang=en: maintenance branch,community interaction,community feature,necessary feature,stable release,ticket system,advanced feature,power users,feature set,chat irc,leading edge,router,new features,members,attempt,development branches,branch development
Expand Up @@ -107,4 +107,4 @@ To get started on your first CakePHP application,

.. meta::
:title lang=en: Understanding Model-View-Controller
:keywords lang=en: model view controller,model layer,formatted result,model objects,music documents,business logic,text representation,first glance,retrieving data,software design,html page,videos music,new friends,interaction,cakephp,interface,photo,presentation,mvc,photos
:keywords lang=en: model view controller,model layer,formatted result,model objects,music documents,business logic,text representation,first glance,retrieving data,software design,html page,videos music,new friends,interaction,cakephp,interface,photo,presentation,mvc,photos
2 changes: 1 addition & 1 deletion en/cakephp-overview/where-to-get-help.rst
Expand Up @@ -96,4 +96,4 @@ and solved questions as well.
.. meta::
:title lang=en: Where to Get Help
:description lang=en: Where to get help with CakePHP: The official CakePHP website, The Cookbook, The Bakery, The API, in the test cases, the IRC channel, The CakePHP Google Group or CakePHP Questions.
:keywords lang=en: cakephp,cakephp help,help with cakephp,where to get help,cakephp irc,cakephp questions,cakephp api,cakephp test cases,open source projects,channel irc,code reference,irc channel,developer tools,test case,bakery
:keywords lang=en: cakephp,cakephp help,help with cakephp,where to get help,cakephp irc,cakephp questions,cakephp api,cakephp test cases,open source projects,channel irc,code reference,irc channel,developer tools,test case,bakery
2 changes: 1 addition & 1 deletion en/console-and-shells/acl-shell.rst
Expand Up @@ -79,4 +79,4 @@ allows you to return only a portion of the requested tree::

.. meta::
:title lang=en: ACL Shell
:keywords lang=en: record style,style reference,acl,database tables,group id,notations,alias,privilege,node,privileges,shell,databases
:keywords lang=en: record style,style reference,acl,database tables,group id,notations,alias,privilege,node,privileges,shell,databases
2 changes: 1 addition & 1 deletion en/console-and-shells/code-generation-with-bake.rst
Expand Up @@ -230,4 +230,4 @@ and add the files there.

.. meta::
:title lang=en: Code Generation with Bake
:keywords lang=en: command line interface,functional application,atabase,database configuration,bash script,basic ingredients,roject,odel,path path,code generation,scaffolding,windows users,configuration file,few minutes,config,iew,shell,models,running,mysql
:keywords lang=en: command line interface,functional application,atabase,database configuration,bash script,basic ingredients,roject,odel,path path,code generation,scaffolding,windows users,configuration file,few minutes,config,iew,shell,models,running,mysql
2 changes: 1 addition & 1 deletion en/console-and-shells/testsuite-shell.rst
Expand Up @@ -14,4 +14,4 @@ For more information on basic usage of the test shell see

.. meta::
:title lang=en: Test Shell
:keywords lang=en: cakephp testing,test shell,testsuite,command line
:keywords lang=en: cakephp testing,test shell,testsuite,command line
2 changes: 1 addition & 1 deletion en/contributing/tickets.rst
Expand Up @@ -51,4 +51,4 @@ CakePHP team will take the following actions:

.. meta::
:title lang=en: Tickets
:keywords lang=en: bug reporting system,code snippet,reporting security,private mailing,release announcement,google,ticket system,core team,security issue,bug tracker,irc channel,test cases,support questions,bug report,security issues,bug reports,exploits,lighthouse,vulnerability,repository
:keywords lang=en: bug reporting system,code snippet,reporting security,private mailing,release announcement,google,ticket system,core team,security issue,bug tracker,irc channel,test cases,support questions,bug report,security issues,bug reports,exploits,lighthouse,vulnerability,repository
2 changes: 1 addition & 1 deletion en/controllers/pages-controller.rst
Expand Up @@ -25,4 +25,4 @@ created in your ``app/Controller/`` folder. You can also copy the file from

.. meta::
:title lang=en: The Pages Controller
:keywords lang=en: pages controller,default controller,lib,cakephp,ships,php,file folder
:keywords lang=en: pages controller,default controller,lib,cakephp,ships,php,file folder
14 changes: 0 additions & 14 deletions en/core-libraries/events.rst
Expand Up @@ -55,7 +55,6 @@ Dispatching events
So back to our example, we would have an `Order` model that will manage the buying logic,
and probably a `place` method to save the order details and do any other logic::

<?php
// Cart/Model/Order.php
class Order extends AppModel {

Expand All @@ -77,7 +76,6 @@ about sending emails, and may not even have the inventory data to decrement the
item from it, and definitely tracking usage statistics is not the best place to
do it. So we need another solution, let's rewrite that using the event manager::

<?php
// Cart/Model/Order.php
App::uses('CakeEvent', 'Event');
class Order extends AppModel {
Expand Down Expand Up @@ -106,7 +104,6 @@ and to dispatch events you use :php:meth:`CakeEventManager::dispatch()` which
receives an instance of the :php:class:`CakeEvent` class. Let's dissect now the
process of dispatching an event::

<?php
new CakeEvent('Model.Order.afterPlace', $this, array(
'order' => $order
));
Expand Down Expand Up @@ -145,7 +142,6 @@ For simplicity's sake, let's imagine we know in the plugin what the callbacks
are available in the controller, and say this controller is responsible for
attaching them. The possible code would look like this::

<?php
// Listeners configured somewhere else, maybe a config file:
Configure::write('Order.afterPlace', array(
'email-sending' => 'EmailSender::sendBuyEmail',
Expand Down Expand Up @@ -199,7 +195,6 @@ statistics. It would be natural to pass an instance of this class as a callback,
instead of implementing a custom static function or converting any other workaround
to trigger methods in this class. A listener is created as follows::

<?php
App::uses('CakeEventListener', 'Event');
class UserStatistic implements CakeEventListener {

Expand Down Expand Up @@ -246,7 +241,6 @@ executed with a `FIFO` policy, the first listener method to be attached is calle
first and so on. You set priorities using the `attach` method for callbacks, and
declaring it in the `implementedEvents` function for event listeners::

<?php
// Setting priority for a callback
$callback = array($this, 'doSomething');
$this->getEventManager()->attach($callback, 'Model.Order.afterPlace', array('priority' => 2));
Expand Down Expand Up @@ -278,7 +272,6 @@ In order to toggle this option you have to add the `passParams` option to the
third argument of the `attach` method, or declare it in the `implementedEvents`
returned array similar to what you do with priorities::

<?php
// Setting priority for a callback
$callback = array($this, 'doSomething');
$this->getEventManager()->attach($callback, 'Model.Order.afterPlace', array('passParams' => true));
Expand All @@ -300,7 +293,6 @@ In the above code the `doSomething` function and `updateBuyStatistic` method wil
receive `$orderData` instead of the `$event` object. This is so, because in our
previous example we trigger the `Model.Order.afterPlace` event with some data::

<?php
$this->getEventManager()->dispatch(new CakeEvent('Model.Order.afterPlace', $this, array(
'order' => $order
)));
Expand All @@ -322,7 +314,6 @@ the code detects it cannot proceed any further.
In order to stop events you can either return `false` in your callbacks or call
the `stopPropagation` method on the event object::

<?php
public function doSomething($event) {
// ...
return false; // stops the event
Expand All @@ -342,7 +333,6 @@ we had a `beforePlace` stopping the event would have a valid meaning.

To check if an event was stopped, you call the `isStopped()` method in the event object::

<?php
public function place($order) {
$event = new CakeEvent('Model.Order.beforePlace', $this, array('order' => $order));
$this->getEventManager()->dispatch($event);
Expand Down Expand Up @@ -370,7 +360,6 @@ the $order data.
Event results can be altered either using the event object result property
directly or returning the value in the callback itself::

<?php
// A listener callback
public function doSomething($event) {
// ...
Expand Down Expand Up @@ -410,7 +399,6 @@ If for any reason you want to remove any callback from the event manager just ca
the :php:meth:`CakeEventManager::detach()` method using as arguments the first two
params you used for attaching it::

<?php
// Attaching a function
$this->getEventManager()->attach(array($this, 'doSomething'), 'My.event');

Expand Down Expand Up @@ -459,7 +447,6 @@ the local callbacks will get called in the respective priority order.
Accessing the global event manager is as easy as calling a static function,
the following example will attach a global event to the `beforePlace` event::

<?php
// In any configuration file or piece of code that executes before the event
App::uses('CakeEventManager', 'Event');
CakeEventManager::instance()->attach($aCallback, 'Model.Order.beforePlace');
Expand All @@ -476,7 +463,6 @@ to prevent some bugs. Remember that extreme flexibility implies extreme complexi
Consider this callback that wants to listen for all Model beforeFinds but in
reality, it cannot do its logic if the model is the Cart::

<?php
App::uses('CakeEventManager', 'Event');
CakeEventManager::instance()->attach('myCallback', 'Model.beforeFind');

Expand Down
3 changes: 1 addition & 2 deletions en/core-libraries/global-constants-and-functions.rst
Expand Up @@ -28,7 +28,6 @@ such as debugging and translating content.
``sprintf()``. You can supply additional arguments to replace
placeholders in your string::

<?php
__('You have %s unread messages', $number);

.. note::
Expand Down Expand Up @@ -308,4 +307,4 @@ Timing Definition Constants

.. meta::
:title lang=en: Global Constants and Functions
:keywords lang=en: internationalization and localization,global constants,example config,array php,convenience functions,core libraries,component classes,optional number,global functions,string string,core classes,format strings,unread messages,placeholders,useful functions,sprintf,arrays,parameters,existence,translations
:keywords lang=en: internationalization and localization,global constants,example config,array php,convenience functions,core libraries,component classes,optional number,global functions,string string,core classes,format strings,unread messages,placeholders,useful functions,sprintf,arrays,parameters,existence,translations
9 changes: 0 additions & 9 deletions en/core-libraries/internationalization-and-localization.rst
Expand Up @@ -82,7 +82,6 @@ Remember that po files are useful for short messages, if you find
you want to translate long paragraphs, or even whole pages - you
should consider implementing a different solution. e.g.::

<?php
// App Controller Code.
public function beforeFilter() {
$locale = Configure::read('Config.language');
Expand All @@ -94,7 +93,6 @@ should consider implementing a different solution. e.g.::

or::

<?php
// View code
echo $this->element(Configure::read('Config.language') . '/tos');

Expand All @@ -107,7 +105,6 @@ follow a few conventions.
Instead of __() and __n() you will have to use __d() and __dn(). The D means
domain. So if you have a plugin called 'DebugKit' you would have to do this::

<?php
__d('debug_kit', 'My example text');

Using the underscored syntax is important, if you don't use it CakePHP won't
Expand All @@ -133,7 +130,6 @@ Localization in CakePHP
To change or set the language for your application, all you need to
do is the following::

<?php
Configure::write('Config.language', 'fre');

This tells Cake which locale to use (if you use a regional locale, such as
Expand All @@ -146,13 +142,11 @@ in fact anytime at all before you want a message in a different language. To
set the language for the current user, you can store the setting in the Session
object, like this::

<?php
$this->Session->write('Config.language', 'fre');

At the beginning of each request in your controller's ``beforeFilter`` you
should configure ``Configure`` as well::

<?php
class AppController extends Controller {
public function beforeFilter() {
Configure::write('Config.language', $this->Session->read('Config.language'));
Expand Down Expand Up @@ -198,7 +192,6 @@ CakePHP will automatically extract the validation error when you are using the
:doc:`i18n console task </console-and-shells>`. By default, the default domain is used.
This can be overwritten by setting the ``$validationDomain`` property in your model::

<?php
class User extends AppModel {

public $validationDomain = 'validation_errors';
Expand All @@ -207,7 +200,6 @@ This can be overwritten by setting the ``$validationDomain`` property in your mo
Additional parameters defined in the validation rule are passed to the translation
function. This allows you to create dynamic validation messages::

<?php
class User extends AppModel {

public $validationDomain = 'validation';
Expand All @@ -224,7 +216,6 @@ function. This allows you to create dynamic validation messages::

Which will do the following internal call::

<?php
__d('validation', 'Username should be between %d and %d characters', array(2, 10));

.. meta::
Expand Down
13 changes: 0 additions & 13 deletions en/core-libraries/logging.rst
Expand Up @@ -32,7 +32,6 @@ configured ``CakeLog`` will attempt to load Configuring log streams
is done by calling ``CakeLog::config()``. Configuring our
DataBaseLogger would look like::
<?php
// for app/Lib
CakeLog::config('otherFile', array(
'engine' => 'DatabaseLogger',
Expand All @@ -51,7 +50,6 @@ When configuring a log stream the ``engine`` parameter is used to
locate and load the log handler. All of the other configuration
properties are passed to the log stream's constructor as an array.::

<?php
App::uses('CakeLogInterface', 'Log');

class DatabaseLogger implements CakeLogInterface {
Expand Down Expand Up @@ -113,7 +111,6 @@ message is stored in. If a type is not supplied, LOG\_ERROR is used
which writes to the error log. The default log location is
``app/tmp/logs/$type.log``::

<?php
// Executing this inside a CakePHP class
$this->log("Something didn't work!");
Expand All @@ -124,7 +121,6 @@ You can specify a custom log name using the first parameter. The
default built-in FileLog class will treat this log name as the file
you wish to write logs to::

<?php
// called statically
CakeLog::write('activity', 'A special message for activity logging');
Expand All @@ -138,7 +134,6 @@ You can configure additional/alternate FileLog locations using
:php:meth:`CakeLog::config()`. FileLog accepts a ``path`` which allows for
custom paths to be used::

<?php
CakeLog::config('custom_path', array(
'engine' => 'FileLog',
'path' => '/path/to/custom/place/'
Expand All @@ -152,14 +147,12 @@ Writing to logs
Writing to the log files can be done in 2 different ways. The first
is to use the static :php:meth:`CakeLog::write()` method::

<?php
CakeLog::write('debug', 'Something did not work');

The second is to use the log() shortcut function available on any
class that extends ``Object``. Calling log() will internally call
CakeLog::write()::

<?php
// Executing this inside a CakePHP class:
$this->log("Something did not work!", 'debug');

Expand Down Expand Up @@ -188,7 +181,6 @@ the log messages will be directed to those loggers. If a log message is written
to an unknown scope, loggers that handle that level of message will log the
message. For example::

<?php
// configure tmp/logs/shops.log to receive all types (log levels), but only
// those with `orders` and `payments` scope
CakeLog::config('shops', array(
Expand Down Expand Up @@ -260,14 +252,12 @@ CakeLog API
To append the additional levels 'user0' and 'user1' to the default
log levels use::

<?php
CakeLog::levels(array('user0', 'user1'));
// or
CakeLog::levels(array('user0', 'user1'), true);

Calling ``CakeLog::levels()`` will result in::

<?php
array(
0 => 'emergency',
1 => 'alert',
Expand All @@ -279,12 +269,10 @@ CakeLog API
To set/replace an existing configuration, pass an array with the second
argument set to false::

<?php
CakeLog::levels(array('user0', 'user1'), false);

Calling ``CakeLog::levels()`` will result in::

<?php
array(
0 => 'user0',
1 => 'user1',
Expand All @@ -296,7 +284,6 @@ CakeLog API

Resets log levels to their original values::

<?php
array(
'emergency' => LOG_EMERG,
'alert' => LOG_ALERT,
Expand Down
2 changes: 1 addition & 1 deletion en/core-libraries/toc-behaviors.rst
Expand Up @@ -7,4 +7,4 @@ Behaviors
behaviors/acl
behaviors/containable
behaviors/translate
behaviors/tree
behaviors/tree
2 changes: 1 addition & 1 deletion en/core-libraries/toc-components.rst
Expand Up @@ -11,4 +11,4 @@ Components
components/request-handling
components/pagination
components/security-component
components/sessions
components/sessions
2 changes: 1 addition & 1 deletion en/core-libraries/toc-general-purpose.rst
Expand Up @@ -7,4 +7,4 @@ General Purpose
global-constants-and-functions
../core-utility-libraries/app
events
collections
collections
2 changes: 1 addition & 1 deletion en/core-libraries/toc-helpers.rst
Expand Up @@ -13,4 +13,4 @@ Helpers
helpers/rss
helpers/session
helpers/text
helpers/time
helpers/time
2 changes: 1 addition & 1 deletion en/core-libraries/toc-utilities.rst
Expand Up @@ -19,4 +19,4 @@ Utilities
../core-utility-libraries/hash
../core-utility-libraries/set
../core-utility-libraries/string
../core-utility-libraries/xml
../core-utility-libraries/xml

0 comments on commit f75866c

Please sign in to comment.