Monday, February 2, 2015

Re: Cake 3.0 - Convenient way to retrieve if the current Table/Behavior is part of a plugin or not

Why do you need to know if something is in a plugin, btw?

On Monday, February 2, 2015 at 10:12:34 AM UTC-4:30, Ernesto wrote:
that "probably" gives me chills :P

what do you think about this solution?

//in my table class
public function plugin()
{
foreach (Configure::read('App.paths.plugins') as $pluginPath) {
if (is_numeric(strpos(strtolower(__FILE__), strtolower($pluginPath)))) {
return string_between(strtolower(__FILE__), strtolower($pluginPath), DS);
}
}
}

//somewhere
function string_between($string, $start, $end)
{
$string = " " . $string;
$ini = strpos($string, $start);
if ($ini == 0) {
return "";
} else {
$ini += strlen($start);
return substr($string, $ini, strpos($string, $end, $ini) - $ini);
}
}

Il giorno venerdì 30 gennaio 2015 23:16:11 UTC+1, José Lorenzo ha scritto:
Check the namespace of the class:

list($namespace, $class) = namespaceSplit(get_class($table));

if ($namespace !== 'App\Model\Table')  // Probably a plugin :)

On Friday, January 30, 2015 at 4:10:31 PM UTC+1, Ernesto wrote:
Hi all

is there a convenient way to retrieve if the current Table/Behavior is part of a plugin or not?

in Controllers and Helpers i can inspect the request object and get it done.

--
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+unsubscribe@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/d/optout.

Re: Soft delete plugin for cakephp 3

Feel free to add it to https://github.com/FriendsOfCake/awesome-cakephp/tree/cake3
Thats the list people would look for plugins and alike :)

mark


Am Sonntag, 1. Februar 2015 03:40:21 UTC+1 schrieb Pgbi:
Hi guys,

For one of my projects, I developed a plugin to nicely handle soft deletion for some of my models. I thought I might share it with the community (hope this is the right place to do it).

Any remarks about it will be appreciated!

--
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+unsubscribe@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/d/optout.

Re: Cake 3.0 - Convenient way to retrieve if the current Table/Behavior is part of a plugin or not

that "probably" gives me chills :P

what do you think about this solution?

//in my table class
public function plugin()
{
foreach (Configure::read('App.paths.plugins') as $pluginPath) {
if (is_numeric(strpos(strtolower(__FILE__), strtolower($pluginPath)))) {
return string_between(strtolower(__FILE__), strtolower($pluginPath), DS);
}
}
}

//somewhere
function string_between($string, $start, $end)
{
$string = " " . $string;
$ini = strpos($string, $start);
if ($ini == 0) {
return "";
} else {
$ini += strlen($start);
return substr($string, $ini, strpos($string, $end, $ini) - $ini);
}
}

Il giorno venerdì 30 gennaio 2015 23:16:11 UTC+1, José Lorenzo ha scritto:
Check the namespace of the class:

list($namespace, $class) = namespaceSplit(get_class($table));

if ($namespace !== 'App\Model\Table')  // Probably a plugin :)

On Friday, January 30, 2015 at 4:10:31 PM UTC+1, Ernesto wrote:
Hi all

is there a convenient way to retrieve if the current Table/Behavior is part of a plugin or not?

in Controllers and Helpers i can inspect the request object and get it done.

--
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+unsubscribe@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/d/optout.

Re: Cake 3.0 - Convenient way to retrieve if the current Table/Behavior is part of a plugin or not

that "probably" gives me chills :P

what do you think about this solution?

//in my table class
public function plugin ()
{
foreach (Configure::read('App.paths.plugins') as $pluginPath) {
return string_between(strtolower(__FILE__), strtolower($pluginPath), DS);
}
}

//somewhere
function string_between($string, $start, $end)
{
$string = " " . $string;
$ini = strpos($string, $start);
if ($ini == 0) {
return "";
} else {
$ini += strlen($start);
return substr($string, $ini, strpos($string, $end, $ini) - $ini);
}
}

Il giorno venerdì 30 gennaio 2015 23:16:11 UTC+1, José Lorenzo ha scritto:
Check the namespace of the class:

list($namespace, $class) = namespaceSplit(get_class($table));

if ($namespace !== 'App\Model\Table')  // Probably a plugin :)

On Friday, January 30, 2015 at 4:10:31 PM UTC+1, Ernesto wrote:
Hi all

is there a convenient way to retrieve if the current Table/Behavior is part of a plugin or not?

in Controllers and Helpers i can inspect the request object and get it done.

--
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+unsubscribe@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/d/optout.

SQL Cartesian Product with CakePHP find

Hi, 

How could I do a cartesian product with 2 different tables in CakePHP 2.x ?

EX:
SELECT t1.id, t1.field, t2.id, td.field
FROM table1 AS t1,
(SELECT t2.id, t2.field FROM table2) AS t2
WHERE t1.id >= 10

note this isn't a join, I need these cartesian product to apply another filter conditions.

--
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+unsubscribe@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/d/optout.

Sunday, February 1, 2015

Re: How to upgrade from 2..5.2 to 2.6.1

ok, thanks for reply.

On Sat, Jan 24, 2015 at 6:00 PM, mark_story <mark.story@gmail.com> wrote:
You will have to replace the lib directory. You will also want to pull in any changes to the config files in app/Config.

-mark

--
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 a topic in the Google Groups "CakePHP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/wDVQBHS_s6k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+unsubscribe@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/d/optout.

--
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+unsubscribe@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/d/optout.

Re: Cakephp Autocomplete Tutorial ajax error

It is best not to use the JS helper(s) etc.
Use just plain jQuery and it will work quite easily out of the box

See http://sandbox.dereuromark.de/sandbox/ajax_examples/ for live examples
mark


Am Sonntag, 1. Februar 2015 01:13:54 UTC+1 schrieb ajt:


In CakePHP, I am trying to create a autocomplete function from a textbox, using this tutorial: http://bakery.cakephp.org/articles/matt_1/2011/08/07/yet_another_jquery_autocomplete_helper_2



I keep getting a

Undefined index: autoCompleteText



I solved the helper issue as it finds the helper as this is cakephp 1.X code and I have 2.X



controller - Tests
function auto_complete



class TestsController extends AppController {

public $helpers = array('Html', 'Form', 'Session','Js','AutoComplete');

 
public function auto_complete() {
 $this
->loadModel('Tutor');
 debug
( $this->params);


    $terms
= $this->Tutor->find('all', array(
       
'conditions' => array(
           
'Tutor.first_name LIKE' => $this->params['url']['autoCompleteText'].'%'
       
),
       
'fields' => array('Tutor.first_name'),
       
'limit' => 3,
       
'recursive'=>-1,
   
));
    $terms
= Set::Extract($terms,'{n}.Tutor.first_name');
    $this
->set('terms', $terms);
    $this
->layout = '';    
}


view
 auto_complete
.ctp



<?php 
echo $this
->AutoComplete->input(
   
'Tutor.first_name',
    array
(
       
'autoCompleteUrl'=>$this->Html->url(
            array
(
               
'controller'=>'tests',
               
'action'=>'auto_complete',
           
)
       
),
       
'autoCompleteRequestItem'=>'autoCompleteText',
   
)
);

 
if(isset($terms)) {
    echo $this
->Js->object($terms);
 
}

       echo $this
->Form->create('');

            echo $this
->Form->input('type', array('label' => 'Choose' ));
           echo $this
->Form->end('send');

 
?>


--
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+unsubscribe@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/d/optout.