Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
lorenzo committed Sep 30, 2011
2 parents 7b8289b + 323bc77 commit b743888f8f05730f8798984b91e4f353d5ff2eda
@@ -85,9 +85,9 @@ public function add($type = null, $foreignKey = null) {
$message = __d('favorites', 'Record was successfully added', true);
} else {
$message = __d('favorites', 'Record was not added.', true);
- }
+ }
} catch (Exception $e) {
- $message = __d('favorites', 'Record was not added. ', true) . $e->getMessage();
+ $message = __d('favorites', 'Record was not added.', true) . ' ' . $e->getMessage();
}
}
}
View
@@ -37,14 +37,10 @@ msgstr ""
msgid "Record was successfully added"
msgstr ""
-#: /controllers/favorites_controller.php:87
+#: /controllers/favorites_controller.php:87;90
msgid "Record was not added."
msgstr ""
-#: /controllers/favorites_controller.php:90
-msgid "Record was not added. "
-msgstr ""
-
#: /controllers/favorites_controller.php:114
msgid "Record removed from list"
msgstr ""
@@ -0,0 +1,92 @@
+# LANGUAGE translation of the CakePHP Categories plugin
+#
+# Copyright 2010, Cake Development Corporation (http://cakedc.com)
+#
+# Licensed under The MIT License
+# Redistributions of files must retain the above copyright notice.
+#
+# @copyright Copyright 2010, Cake Development Corporation (http://cakedc.com)
+# @license MIT License (http://www.opensource.org/licenses/mit-license.php)
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: CakePHP Favorites Plugin\n"
+"POT-Creation-Date: 2010-09-15 15:11+0200\n"
+"PO-Revision-Date: 2010-09-23 16:32-0300\n"
+"Last-Translator: Renan Gonçalves <renan.saddam@gmail.com>\n"
+"Language-Team: CakeDC <renan.saddam@gmail.com>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2;plural=n>1;\n"
+"X-Poedit-Language: Portuguese\n"
+"X-Poedit-Country: BRAZIL\n"
+
+#: /controllers/favorites_controller.php:59
+msgid "Authentification required"
+msgstr "Autentificação exigida"
+
+#: /controllers/favorites_controller.php:72;132;150
+msgid "Invalid object type."
+msgstr "Tipo de objeto inválido."
+
+#: /controllers/favorites_controller.php:79
+msgid "Invalid identifier"
+msgstr "Identificador inválido"
+
+#: /controllers/favorites_controller.php:85
+msgid "Record was successfully added"
+msgstr "Registro foi adicionado com sucesso"
+
+#: /controllers/favorites_controller.php:87;90
+msgid "Record was not added."
+msgstr "Registro não foi adicionado."
+
+#: /controllers/favorites_controller.php:114
+msgid "Record removed from list"
+msgstr "Registro removido da lista"
+
+#: /controllers/favorites_controller.php:116
+msgid "Unable to delete favorite, please try again"
+msgstr "Não foi possível remover o favorito, por favor tente novamente"
+
+#: /controllers/favorites_controller.php:172
+msgid "Invalid direction"
+msgstr "Direção inválida"
+
+#: /controllers/favorites_controller.php:175
+msgid "Favorite positions updated."
+msgstr "Posições do favorito atualizadas."
+
+#: /controllers/favorites_controller.php:177
+msgid "Unable to change favorite position, please try again"
+msgstr "Não foi possível alterar a posição do favorito, por favor tente novamente"
+
+#: /controllers/favorites_controller.php:226
+msgid "That record does not exist."
+msgstr "Esse registro não existe."
+
+#: /controllers/favorites_controller.php:229
+msgid "That record does not belong to you."
+msgstr "Esse registro não pertence a você."
+
+#: /models/behaviors/favorite.php:130
+msgid "Operation is not allowed"
+msgstr "Operação não permitida"
+
+#: /models/behaviors/favorite.php:141
+msgid "Already added."
+msgstr "Já adicionado."
+
+#: /models/behaviors/favorite.php:151
+msgid "You cannot add more than %s items to this list"
+msgstr "Você não pode adicionar mais que %s itens nesta lista"
+
+#: /views/favorites/list.ctp:17
+msgid "You have no favorites in this category."
+msgstr "Você não possui favoritos nesta categoria."
+
+#: /views/helpers/favorites.php:76
+msgid "Incorrect favorite type \"%s\"."
+msgstr "Tipo incorreto de favorito \"%s\"."
+
@@ -0,0 +1,88 @@
+# LANGUAGE translation of the CakePHP Categories plugin
+#
+# Copyright 2010, Cake Development Corporation (http://cakedc.com)
+#
+# Licensed under The MIT License
+# Redistributions of files must retain the above copyright notice.
+#
+# @copyright Copyright 2010, Cake Development Corporation (http://cakedc.com)
+# @license MIT License (http://www.opensource.org/licenses/mit-license.php)
+#
+"Project-Id-Version: Favorites CakePHP plugin\n"
+"POT-Creation-Date: 2010-09-15 15:11+0200\n"
+"PO-Revision-Date: 2010-09-24 13:18-0400\n"
+"Last-Translator: José Lorenzo Rodríguez <jose.lorenzo@cakedc.com>\n"
+"Language-Team: CakeDC <contact@cakedc.com>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-Language: Spanish\n"
+
+#: /controllers/favorites_controller.php:59
+msgid "Authentification required"
+msgstr "Autenticación Requerida"
+
+#: /controllers/favorites_controller.php:72;132;150
+msgid "Invalid object type."
+msgstr "Tipo de objecto no válido"
+
+#: /controllers/favorites_controller.php:79
+msgid "Invalid identifier"
+msgstr "Identificador no válido"
+
+#: /controllers/favorites_controller.php:85
+msgid "Record was successfully added"
+msgstr "El registro fue agregado exitosamente"
+
+#: /controllers/favorites_controller.php:87;90
+msgid "Record was not added."
+msgstr "El registro no fue agregado"
+
+#: /controllers/favorites_controller.php:114
+msgid "Record removed from list"
+msgstr "Registro eliminado de la lista"
+
+#: /controllers/favorites_controller.php:116
+msgid "Unable to delete favorite, please try again"
+msgstr "No es posible eliminar el favorito, por favor intente nuevamente"
+
+#: /controllers/favorites_controller.php:172
+msgid "Invalid direction"
+msgstr "Dirección no válida"
+
+#: /controllers/favorites_controller.php:175
+msgid "Favorite positions updated."
+msgstr "Posiciones de favoritos actualizadas."
+
+#: /controllers/favorites_controller.php:177
+msgid "Unable to change favorite position, please try again"
+msgstr "No es posible cambiar la posición del favorito, por favor intente de nuevo"
+
+#: /controllers/favorites_controller.php:226
+msgid "That record does not exist."
+msgstr "No existe tal registro."
+
+#: /controllers/favorites_controller.php:229
+msgid "That record does not belong to you."
+msgstr "El registro no te pertenece."
+
+#: /models/behaviors/favorite.php:130
+msgid "Operation is not allowed"
+msgstr "Operación no permitida"
+
+#: /models/behaviors/favorite.php:141
+msgid "Already added."
+msgstr "Ya fue añadido"
+
+#: /models/behaviors/favorite.php:151
+msgid "You cannot add more than %s items to this list"
+msgstr "No se pueden añadir más de %s elementos a esta lista"
+
+#: /views/favorites/list.ctp:17
+msgid "You have no favorites in this category."
+msgstr "No tiene favoritos en esta categoría."
+
+#: /views/helpers/favorites.php:76
+msgid "Incorrect favorite type \"%s\"."
+msgstr "Favorito incorrecto de tipo \"%s\"."
+
@@ -1,25 +1,12 @@
<?php
/**
- * Favorite Behavior
+ * Copyright 2009-2010, Cake Development Corporation (http://cakedc.com)
*
- * Attach to a Model to create hasMany relationship with Favorite model and
- * include counterCache, also provides some utility methods for favorites, like reordering,
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
*
- * PHP versions 4 and 5
- *
- * Copyright 2007-2008, Cake Development Corporation
- * 1785 E. Sahara Avenue, Suite 490-423
- * Las Vegas, Nevada 89104
- *
- * You may obtain a copy of the License at:
- * License page: http://projects.cakedc.com/licenses/TBD TBD
- * Copyright page: http://converge.cakedc.com/copyright/
- *
- * @filesource
- * @copyright Copyright 2007-2008, Cake Development Corporation
- * @link
- * @package favorites
- * @subpackage favorites.models.behaviors
+ * @copyright Copyright 2009-2010, Cake Development Corporation (http://cakedc.com)
+ * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
View
@@ -111,6 +111,29 @@ public function getFavorites($userId, $options) {
return $favorites;
}
+/**
+ * Returns all the favorites a given User has added
+ *
+ * @param string $id User id
+ * @param array $options query options to be passed to the find method
+ * @return array Favorite list with the favorites keys
+ * Each key will have a value like the following:
+ * array(
+ * 'favorite-id1' => 'foreign-key1',
+ * 'favorite-id2' => 'foreign-key2')
+ * @access public
+ */
+ public function getAllFavorites($id = null, $options = array()) {
+ $keys = array_keys(Configure::read('Favorites.types'));
+ $result = array_fill_keys($keys, array());
+ if (!is_null($id)) {
+ $list = $this->getFavorites($id, array('type' => $keys) + $options);
+ $list = Set::combine($list, '{n}.Favorite.id', '{n}.Favorite.foreign_key', '{n}.Favorite.type');
+ $result = array_merge($result, $list);
+ }
+ return $result;
+ }
+
/**
* Returns the search data
@@ -294,7 +317,7 @@ public function isFavorited($modelName, $type, $foreignKey, $userId) {
*/
public function getFavoriteId($modelName, $type, $foreignKey, $userId) {
$favoriteId = false;
-
+
$record = $this->find('first', array(
'fields' => array($this->alias . '.' . $this->primaryKey),
'conditions' => array(
@@ -308,7 +331,7 @@ public function getFavoriteId($modelName, $type, $foreignKey, $userId) {
if (isset($record[$this->alias][$this->primaryKey])) {
$favoriteId = $record[$this->alias][$this->primaryKey];
}
-
+
return $favoriteId;
}
@@ -361,15 +384,16 @@ public function deleteRecord($id) {
}
$record = $record[$this->alias];
$model = $record['model'];
+ $Model = ClassRegistry::init($model);
$result = $this->delete($id);
if ($result) {
- $Model = ClassRegistry::init($model);
if (method_exists($Model, 'afterDeleteFavorite')) {
$result = $Model->afterDeleteFavorite(array('id' => $record['foreign_key'], 'userId' => $record['user_id'], 'model' => $model, 'type' => $record['type']));
}
return $result;
}
return $result;
}
-
+
}
+
Oops, something went wrong.

0 comments on commit b743888

Please sign in to comment.