Problems with the Translate Beahvior in Cake 2.3.7

2013-07-07 Thread Hervé Thouzard
Hello,

I have many problems with the translate behavior.
Here is my configuration.

At the top of bootstrap.php I have :

 Configure::write('Config.languages', array('eng', 'fra', 'ita'));
 Configure::write('Config.language', 'fra');


My model, a very simple Post model with id, title, content, created, 
modified :

class Post extends AppModel {
 public $displayField = 'title';
 public $actsAs = array(
 'Translate' = array(
 'title' = '_title',
 'content' = '_content',
 )
 );
 public $validate = array(
 'title' = array(
 'notempty' = array(
 'rule' = array('notempty'),
 'message' = Veuillez renseigner un titre,
 ),
 ),
 );
 }


An extract from my controler :

 public function admin_view($id = null) {
 if (!$this-Post-exists($id)) {
 throw new NotFoundException(__('Invalid post'));
 }
 $this-Post-id = $id;
 $this-set('post', $this-Post-read());
 }


And my view :

h2?php  echo __('Post'); ?/h2
 dl
 dt?php echo __('Id'); ?/dt
 dd
 ?php echo h($post['Post']['id']); ?
 nbsp;
 /dd
 dt?php echo __('Title'); ?/dt
 dd
 ?php echo h($post['Post']['title']); ?
 nbsp;
 /dd
 dt?php echo __('Content'); ?/dt
 dd
 ?php echo h($post['Post']['content']); ?
 nbsp;
 /dd
 dt?php echo __('Created'); ?/dt
 dd
 ?php echo h($post['Post']['created']); ?
 nbsp;
 /dd
 dt?php echo __('Modified'); ?/dt
 dd
 ?php echo h($post['Post']['modified']); ?
 nbsp;
 /dd
 /dl
 /div


That's standard code mostly generated by bake.
An extract from my database :

CREATE TABLE `i18n` (
   `id` int(10) NOT NULL AUTO_INCREMENT,
   `locale` varchar(6) NOT NULL,
   `model` varchar(255) NOT NULL,
   `foreign_key` int(10) NOT NULL,
   `field` varchar(255) NOT NULL,
   `content` text,
   PRIMARY KEY (`id`),
   KEY `locale` (`locale`),
   KEY `model` (`model`),
   KEY `row_id` (`foreign_key`),
   KEY `field` (`field`)
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
 INSERT INTO `i18n` VALUES(19, 'eng', 'Post', 4, 'title', 'en  title 4');
 INSERT INTO `i18n` VALUES(20, 'fra', 'Post', 4, 'title', 'fr titre 4');
 INSERT INTO `i18n` VALUES(21, 'ita', 'Post', 4, 'title', 'it titla 4');
 INSERT INTO `i18n` VALUES(22, 'eng', 'Post', 4, 'content', 'en content 4');
 INSERT INTO `i18n` VALUES(23, 'fra', 'Post', 4, 'content', 'fr contenu 4');
 INSERT INTO `i18n` VALUES(24, 'ita', 'Post', 4, 'content', 'it contena 4');
 CREATE TABLE `posts` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `title` varchar(255) NOT NULL,
   `content` text NOT NULL,
   `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE 
 CURRENT_TIMESTAMP,
   `modified` datetime NOT NULL DEFAULT '-00-00 00:00:00',
   PRIMARY KEY (`id`),
   KEY `created` (`created`)
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
 INSERT INTO `posts` VALUES(4, 'en  title 4', 'en content 4', '-00-00 
 00:00:00', '-00-00 00:00:00');



With this default configuration when I go to 
http://localhost/multilangues/admin/posts/view/4
The view displays :
Id4  Titre Contenu Créée le-00-00 00:00:00  Modifié-00-00 00:00:00  


Nothing for the title and the content.

If I modify my model like this :

public $actsAs = array(
 'Translate' = array(
 'title',
 'content,
 )
 );


Then the display is correct :
Id4  Titrefr titre 4  Contenufr contenu 4  Créée le-00-00 00:00:00  
Modifié-00-00 00:00:00   

I have the title and the content.
But I will not have all the different translated values in the different 
locales to edit my post in all its languages...

Can someone help me please ?

Bye,
Hervé


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Twilio integration with cakephp

2013-07-07 Thread Yasir Arafat Hasib
Hello everybody.
I am integrating twilio with cakephp. I hoped integration is done but after
2/3 rings the call are droping and also i failed to get the call record.

I got others data fine after call end on my database.

-- 
*Thanks  Regards.
-
Yasir Arafat (Hasib)*

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Localized plugin error: Could not find BrValidation class

2013-07-07 Thread Ribamar FS
Apgrade to 2.3.7 without problem with Localizad.
All ok.

Em domingo, 30 de junho de 2013 08h29min50s UTC-3, Ribamar FS escreveu:

 Hi!

 My Cake - 2.3.6

 Download localized plugin and copy  to app/Plugin (Localized)
 Add in app/Config/bootstrap.php:
 CakePlugin::load('Localized'); 

 Add to model:
 App::uses('BrValidation', 'Localized.Validation');

 Validation:
 public $validate = array(
 'cpf' = array(
 'valid' = array(
 'rule' = array('ssn', null, 'br'),
 'required' = true,
 'message' = 'CPF inválido!'
 )
 ),
 );

 On try to add a new register receive:

 *Warning* (512): Could not find BrValidation class, unable to complete 
 validation. [*CORE/Cake/Utility/Validation.php*, line *799*]

 Any tip is welcome.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Twilio integration with cakephp

2013-07-07 Thread Robert Gravel
this is the setup in my controller for voice broadcast in cake 1.3.
Probably not the best code but it works for me.

if($this-data['Recording']['voice_broadcast'] == voice_recording){
App::import('Vendor', 'Twilio', array('file' =
'twilio'.DS.'Services'.DS.'Twilio.php'));
$this-loadModel('Smstwilio');
$this-Smstwilio-recursive = 0;
$smsOptions_array = $this-Smstwilio-find('all',
array('conditions' = array('Smstwilio.school_id' =
$session_school_id)));
$account_sid =
$smsOptions_array['0']['Smstwilio']['account_sid'];
$auth_token =
$smsOptions_array['0']['Smstwilio']['auth_token'];
$client = new Services_Twilio($account_sid, $auth_token);

$this-loadModel('Recording');
$this-Recording-recursive = 0;
$recording =
$this-Recording-findById($this-data['Queue']['recording']);

foreach($users_data as $user){
$call_number = ;
//check for phone or cell phone missing on user. if
missing use the household head phone
if((empty($user['User']['phone'])) ||
(empty($user['User']['cell_phone']))) {
//find the head of household using user
household_id and is_head = 1
$head = $this-User-find('all', array('conditions'
= array('User.household_id' = $user['User']['household_id'],
'User.is_head' = '1')));

//set user email with head email
if (empty($user['User']['phone'])) {
$user['User']['phone'] =
$head[0]['User']['phone'];
}
if (empty($user['User']['cell_phone'])) {
$user['User']['cell_phone'] =
$head[0]['User']['cell_phone'];
}

}
if($this-data['Recording']['phone_type'] == 0){
if($user['User']['phone']){
$call_number = $user['User']['phone'];
}elseif($user['User']['cell_phone']){
$call_number = $user['User']['cell_phone'];
}
}else{
if($user['User']['cell_phone']){
$call_number = $user['User']['cell_phone'];
}elseif($user['User']['phone']){
$call_number = $user['User']['phone'];
}
}

if(!empty($call_number)){
$options = array(IfMachine = Continue);
try{
$call = $client-account-calls-create(

$smsOptions_array['0']['Smstwilio']['phone_number'], // From this number
$call_number, // Call this number

'
http://www.domain.com/queues/play_recording.xml?recording_url='.$recording['Recording']['recording_url']
,
$options
);
}catch (Exception $ex){
echo $ex-getMessage();
}
}
} //end foreach
$this-Session-setFlash(__('The Recording has been sent',
true));
$this-redirect(array('action'='download4'));
}


On Sun, Jul 7, 2013 at 8:23 AM, Yasir Arafat Hasib arafa...@gmail.comwrote:

 Hello everybody.
 I am integrating twilio with cakephp. I hoped integration is done but
 after 2/3 rings the call are droping and also i failed to get the call
 record.

 I got others data fine after call end on my database.

 --
 *Thanks  Regards.

 -
 Yasir Arafat (Hasib)*

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.