本文整理汇总了PHP中inflector::camelize方法的典型用法代码示例。如果您正苦于以下问题:PHP inflector::camelize方法的具体用法?PHP inflector::camelize怎么用?PHP inflector::camelize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inflector
的用法示例。
在下文中一共展示了inflector::camelize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
$reviews = array();
$this->params = $this->data;
$conditions = array("OwnerReply.owner_reply_approved = 0", "OwnerReply.owner_reply_text<>''");
$replies = $this->OwnerReply->findAll(array('fields' => array('CASE WHEN CHAR_LENGTH(User.name) THEN User.name ELSE OwnerReply.name END AS `User.name`', 'OwnerReply.email AS `User.email`'), 'conditions' => $conditions, 'joins' => array('LEFT JOIN #__users AS User ON User.id = OwnerReply.userid'), 'offset' => $this->offset, 'limit' => $this->limit, 'order' => array('OwnerReply.owner_reply_created DESC')));
$total = $this->OwnerReply->findCount(array('conditions' => $conditions));
if (!empty($replies)) {
$predefined_replies = $this->PredefinedReply->findAll(array('fields' => array('PredefinedReply.*'), 'conditions' => array('reply_type = "owner_reply"')));
$this->Review->runProcessRatings = false;
$this->EverywhereAfterFind = true;
// Triggers the afterFind in the Observer Model
// Complete the owner info for each reply
// Get the review info for each reply
$reviews = $this->Review->findAll(array('conditions' => 'Review.id IN (' . implode(',', array_keys($replies)) . ')'));
# Pre-process all urls to sef
$this->_getListingSefUrls($reviews);
$this->_getReviewSefUrls($reviews);
foreach ($replies as $key => $reply) {
// Automagically load and initialize Everywhere Model to check if user is listing owner
if (!isset($this->__loaded[$reply['Review']['extension']])) {
App::import('Model', 'everywhere_' . $reply['Review']['extension'], 'jreviews');
$class_name = inflector::camelize('everywhere_' . $reply['Review']['extension']) . 'Model';
if (class_exists($class_name)) {
${$reply['Review']['extension']} = new $class_name();
}
}
$replies[$key]['Owner'] = ${$reply['Review']['extension']}->getListingOwner($reply['Review']['listing_id']);
isset($reviews[$reply['Review']['review_id']]) and $replies[$key] = array_merge($replies[$key], $reviews[$reply['Review']['review_id']]);
}
}
$this->set(array('total' => $total, 'owner_replies' => $replies, 'predefined_replies' => !empty($predefined_replies) ? $predefined_replies : array()));
return $this->render('owner_replies', 'moderation');
}
示例2: index
function index()
{
$module_id = Sanitize::getInt($this->params, 'module_id', Sanitize::getInt($this->data, 'module_id'));
$this->viewSuffix = Sanitize::getString($this->params['module'], 'tmpl_suffix');
$cache_file = 'modules_totals_' . $module_id . '_' . md5(serialize($this->params['module']));
$page = $this->cached($cache_file);
if ($page) {
return $page;
}
// Initialize variables
$extension = Sanitize::getString($this->params['module'], 'extension');
// Automagically load and initialize Everywhere Model
App::import('Model', 'everywhere_' . $extension, 'jreviews');
$class_name = inflector::camelize('everywhere_' . $extension) . 'Model';
$conditions_reviews = array('Review.published = 1');
$extension == 'com_content' and $conditions_listings = array('Listing.state = 1');
$extension != '' and $conditions_reviews[] = "Review.mode = " . $this->quote($extension);
if (class_exists($class_name)) {
$this->Listing = new $class_name();
$this->Listing->_user = $this->_user;
$listings = $this->Listing->findCount(array('conditions' => $conditions_listings), 'DISTINCT Listing.' . $this->Listing->realKey);
$reviews = $this->Review->findCount(array('conditions' => $conditions_reviews), 'DISTINCT Review.id');
}
# Send variables to view template
$this->set(array('listing_count' => isset($listings) ? $listings : 0, 'review_count' => isset($reviews) ? $reviews : 0));
$page = $this->render('modules', 'totals');
# Save cached version
$this->cacheView('modules', 'totals', $cache_file, $page);
return $page;
}
示例3: beforeFilter
function beforeFilter()
{
parent::beforeFilter();
if (Sanitize::getInt($this->data, 'OwnerReply')) {
$this->review_id = Sanitize::getInt($this->data['OwnerReply'], 'id');
} else {
$this->review_id = Sanitize::getInt($this->params, 'review_id');
}
if (!$this->Config->owner_replies || $this->review_id == 0 || $this->_user->id == 0) {
$this->denyAccess = true;
return;
}
// Get the listing id and extension
$this->_db->setQuery("\n SELECT \n Review.pid AS listing_id, Review.`mode` AS extension\n FROM \n #__jreviews_comments AS Review\n WHERE \n Review.id = " . $this->review_id);
// Get listing owner id and check if it matches the current user
if ($listing = current($this->_db->loadAssocList())) {
// Automagically load and initialize Everywhere Model to check if user is listing owner
App::import('Model', 'everywhere_' . $listing['extension'], 'jreviews');
$class_name = inflector::camelize('everywhere_' . $listing['extension']) . 'Model';
if (class_exists($class_name)) {
$this->Listing = new $class_name();
$owner = $this->Listing->getListingOwner($listing['listing_id']);
if ($this->_user->id != $owner['user_id']) {
$this->denyAccess = true;
return;
}
$this->data['Listing']['created_by'] = $owner['user_id'];
// Used in the Activities component
$this->data['Listing']['listing_id'] = $listing['listing_id'];
// Used in the Activities component
$this->data['Listing']['extension'] = $listing['extension'];
// Used in the Activities component
}
}
}
示例4: add_row
/**
* Add a row to the current data set
*
* @param array $row
*/
public function add_row($row)
{
$keyed_row = array();
foreach ($row as $k => $v) {
$keyed_row[inflector::camelize($this->columns[$k])] = $v;
}
$this->rows[] = $keyed_row;
}
示例5: __initModels
function __initModels($models = null)
{
$models = !empty($models) ? $models : $this->uses;
if (!empty($models)) {
App::import('Model', $models, $this->app);
foreach ($models as $model) {
$method_name = inflector::camelize($model);
$class_name = $method_name . 'Model';
$this->{$method_name} = new $class_name();
}
}
}
示例6: __initModels
function __initModels($models = null, $app = 'jreviews')
{
if (!empty($models)) {
if (!empty($models)) {
App::import('Model', $models, $app);
foreach ($models as $model) {
$method_name = inflector::camelize($model);
$class_name = $method_name . 'Model';
$this->{$method_name} = new $class_name();
}
}
}
}
示例7: __construct
function __construct($app = 'jreviews')
{
if (!empty($this->helpers)) {
$this->app = $app;
App::import('Helper', $this->helpers, $this->app);
foreach ($this->helpers as $helper) {
$method_name = inflector::camelize($helper);
$class_name = $method_name . 'Helper';
if (!isset($this->loaded[$method_name])) {
$this->{$method_name} = registerClass::getInstance($class_name);
$this->loaded[$method_name] =& ${$method_name};
}
}
}
}
示例8: xajaxDispatch
function xajaxDispatch()
{
# MVC initalization script
if (!defined('MVC_FRAMEWORK')) {
require dirname(dirname(__FILE__)) . DS . 'com_jreviews' . DS . 'jreviews' . DS . 'framework.php';
}
$objResponse = new xajaxResponse();
# Debug
if (S2_DEBUG == 0) {
error_reporting(0);
}
# Function parameters
$args = func_get_args();
$controllerName = (string) array_shift($args);
$action = (string) array_shift($args);
$app = isset($args[0]) && is_string($args[0]) ? array_shift($args) : 'jreviews';
App::import('Controller', $controllerName, $app);
# remove admin path from controller name
$controllerClass = inflector::camelize(str_replace(MVC_ADMIN . _DS, '', $controllerName)) . 'Controller';
$controller = new $controllerClass($app);
$controller->app = $app;
$controller->passedArgs = array();
if (isset($args[0])) {
$post = S2Dispatcher::parseParamsAjax($args[0]);
if (isset($post['data'])) {
// pass form inputs to controller variable
$rawData = $post['data'];
$data = Sanitize::clean($post['data']);
$data['__raw'] = $rawData;
$controller->data = $data;
}
$controller->passedArgs = $post;
$controller->params = $post;
}
$controller->name = $controllerName;
$controller->action = $action;
$controller->autoLayout = false;
$controller->autoRender = false;
$controller->xajaxRequest = true;
$controller->__initComponents();
if (method_exists($controller, 'beforeFilter')) {
$controller->beforeFilter();
}
$objResponse->loadCommands($controller->{$action}($args));
return $objResponse;
}
示例9: loadListingModel
/**
* Dynamic Listing Model Loading for jReviewsEverywhere extensions
* Detects which extension is being used to load the correct Listing model
*
* @param object $controller
* @param string $extension
*/
function loadListingModel(&$controller, $extension = null)
{
if (in_array($controller->name, array('admin/reviews', 'reviews')) && $controller->action == '_save') {
$extension = Sanitize::getString($controller->data['Review'], 'mode');
!$extension and isset($controller->data['Listing']) and $extension = Sanitize::getString($controller->data['Listing'], 'extension');
} else {
$extension = $extension ? $extension : Sanitize::getString($controller->params, 'extension', Sanitize::getString($controller->data, 'extension'));
}
if (!$extension && isset($controller->params['module'])) {
// Final check for module parameter
$extension = Sanitize::getString($controller->params['module'], 'extension');
}
$extension == '' and $controller->name != 'facebook' and $controller->name != 'reviews' and $controller->name != 'community_reviews' and $controller->name != 'module_reviews' and $controller->name != 'discussions' and $controller->name != 'admin/reviews' and $controller->name != 'admin/admin_owner_replies' and $controller->name != 'admin/admin_reports' and $controller->name != 'admin/admin_discussions' and $extension = 'com_content';
// Check if in listing detail page and it's a 3rd party component to dynamically load it's Listing model
if ($extension) {
$name = $this->name . '_' . $extension;
App::import('Model', $name, 'jreviews');
$class_name = inflector::camelize($this->name . '_' . $extension) . 'Model';
if ($extension != '' && class_exists($class_name)) {
$controller->Listing = new $class_name($controller->params);
if (isset($controller->Review) && $controller->action != '_save') {
unset($controller->Review->joins['listings'], $controller->Review->joins['jreviews_categories'], $controller->Review->joins['criteria']);
$controller->Review->joins = array_merge($controller->Review->joins, $controller->Listing->joinsReviews);
}
} else {
// Extension used in url doesn't have a plugin so we redirect to 404 error page
$controller->autoLayout = false;
$controller->autoRender = true;
cmsFramework::redirect(cmsFramework::route('index.php?option=com_jreviews&url=404'));
}
}
}
示例10: dispatch
function dispatch()
{
$args = func_get_args();
if (count($args) == 2) {
$url = $args[0];
$additionalParams = $args[1];
} elseif (count($args) == 1) {
$url = null;
$additionalParams = $args[0];
} else {
$url = null;
$additionalParams = array();
}
if ($url !== null) {
$_GET['url'] = $url;
} elseif (isset($_REQUEST['url'])) {
$_GET['url'] = $_REQUEST['url'];
// Non-latin characters are wrong in $_GET array
}
if (isset($_POST['url'])) {
$_GET['url'] = $_POST['url'];
}
// For ajax calls via url param
$this->params = array_insert($this->parseParams($_SERVER['REQUEST_URI']), $additionalParams);
$this->controller = Sanitize::getString($this->params['data'], 'controller');
$this->action = Sanitize::getString($this->params['data'], 'action', 'index');
$cache_url = $this->getUrl();
$this->here = $this->base . '/' . $cache_url;
if (!defined('MVC_FRAMEWORK_ADMIN') && ($cached = $this->cached($cache_url))) {
return $cached;
}
if (!$this->controller || (!isset($_POST) || empty($_POST)) && $this->action[0] == '_' && !$this->isAjax()) {
return $this->error404();
} else {
App::import('Controller', $this->controller, $this->app);
# remove admin path from controller name
$controllerClass = inflector::camelize(str_replace(MVC_ADMIN . _DS, '', $this->controller)) . 'Controller';
$controller = new $controllerClass($this->app);
$controller->app = $this->app;
$controller->base = $this->base;
$controller->here = $this->here;
$controller->params =& $this->params;
$controller->name = $this->controller;
$controller->action = $this->action;
$controller->ajaxRequest = $this->isAjax();
$controller->xajaxRequest = false;
if (!method_exists($controller, $this->action)) {
return $this->error404();
}
$controller->passedArgs = $this->params['url'];
# Copy post array to data array
if (isset($this->params['data'])) {
$rawData = $this->params['data'];
$data = Sanitize::clean($this->params['data']);
$data['__raw'] = $rawData;
$controller->data = $data;
}
$controller->__initComponents();
if (in_array('return', array_keys($this->params)) && $this->params['return'] == 1 || $controller->ajaxRequest) {
$controller->autoRender = false;
}
if (!empty($this->params['bare']) || $controller->ajaxRequest) {
$controller->autoLayout = false;
}
if (isset($this->params['layout'])) {
if ($this->params['layout'] === '') {
$controller->autoLayout = false;
} else {
$controller->layout = $this->params['layout'];
}
}
$controller->beforeFilter();
$output = $controller->{$controller->action}($this->params);
}
$controller->output =& $output;
# Instantiate view class and let it handle ouput
if ($controller->autoRender) {
$controller->render($controller->name, $controller->action, $controller->layout);
$controller->afterFilter();
} else {
$controller->afterFilter();
return $controller->output;
}
}
示例11: saveListingTotals
/**
* Saves totals for the listing after any kind of reviews update (save, publish, delete, change weights etc.)
* @return boolean
*/
function saveListingTotals($listing_id, $extension, $weights = array())
{
if (empty($weights)) {
// Load listings' Everywhere model
$file_name = 'everywhere' . '_' . $extension;
$class_name = inflector::camelize($file_name) . 'Model';
App::import('Model', $file_name, 'jreviews');
$ListingModel = new $class_name();
$weights = $ListingModel->findRow(array('fields' => 'Criteria.weights AS `Criteria.weights`', 'conditions' => "Listing.{$ListingModel->realKey} = {$listing_id}"), array());
unset($ListingModel);
$weights = explode("\n", trim($weights['Criteria']['weights']));
}
$reviewTypes['user'] = 0;
# user reviews
# editor reviews only in com_content
if ($extension == 'com_content') {
$reviewTypes['editor'] = 1;
}
# initiate the results array now moved before the foreach
$data['Totals'] = array('listing_id' => $listing_id, 'extension' => $extension);
# encompassing all calculations with foreach (procedures like changing the review type can affect both averages)
foreach ($reviewTypes as $reviewType => $reviewTypeValue) {
# count comments
$query = "\n SELECT COUNT(*)\n FROM #__jreviews_comments\n WHERE\n pid = {$listing_id}\n AND mode = '{$extension}'\n AND published = 1\n AND author = {$reviewTypeValue}\n ";
$this->_db->setQuery($query);
$data['Totals'][$reviewType . '_comment_count'] = $this->_db->loadResult();
if (empty($data['Totals'][$reviewType . '_comment_count'])) {
# listing deletion moved after the foreach. instead populate the relevant array elements with empty values and move on
$data['Totals'] += array_fill_keys(array($reviewType . '_rating', $reviewType . '_rating_count', $reviewType . '_criteria_rating', $reviewType . '_criteria_rating_count'), '');
continue;
}
$reviewsExist = 1;
# to be used after the foreach
// Now, do ratings exist?
$query = "SELECT Rating.ratings" . "\n FROM #__jreviews_comments AS Review" . "\n INNER JOIN #__jreviews_ratings AS Rating ON Review.id = Rating.reviewid" . "\n WHERE Review.pid = '{$listing_id}' AND Review.published = 1" . "\n AND Review.author = {$reviewTypeValue}" . "\n AND Review.mode = '{$extension}'";
$this->_db->setQuery($query);
$rows = $this->_db->loadAssocList();
if (!empty($rows)) {
// Ratings exist, begin calculations
$weighted = is_array($weights) && array_sum($weights) == 100 ? 1 : 0;
$reviewCount = 0;
$sumRatings = array();
# must init so values from previous foreach iteration won't be used
// This is used like reviewCount, but for each criterion separately.
// Preparing the inital array here, see later on for its use
$reviewCountForCriterion = array_fill(0, count(explode(',', $rows[0]['ratings'])), 0);
foreach ($rows as $rating) {
$ratings_array = explode(',', $rating['ratings']);
// if all is N/A, do not count this review towards the average
if (array_sum($ratings_array) != 0) {
$reviewCount++;
}
// Calculates the totals for each criteria
for ($j = 0; $j < count($ratings_array); $j++) {
if (isset($sumRatings[$j])) {
$sumRatings[$j] += $ratings_array[$j];
} else {
$sumRatings[$j] = $ratings_array[$j];
}
/// If value is N/A, do not count this review towards the criterion average.
if (isset($reviewCountForCriterion[$j]) && $ratings_array[$j] != 0) {
$reviewCountForCriterion[$j]++;
}
}
}
# creates criteria averages.
$ratings = array_map(create_function('$el, $revCount', 'return empty($revCount) ? "na" : number_format($el / $revCount, 4);'), $sumRatings, $reviewCountForCriterion);
$userRating = 'na';
if ($reviewCount > 0) {
if ($weighted) {
# calculate sum of valid weights (=whose ratings aren't n/a)
$sumWeights = array_sum(array_intersect_key($weights, array_filter($sumRatings, create_function('$el', 'return !empty($el) && $el != "na";'))));
if ($sumWeights > 0) {
foreach ($ratings as $k => $v) {
$userRating += $v * $weights[$k] / $sumWeights;
}
}
} else {
# calculate the average, count criteria averages without the n/a ones
$userRating = array_sum($ratings) / count(array_filter($ratings, create_function('$el', 'return !empty($el) && $el != "na";')));
}
}
# if ( $reviewCount > 0 )
// populate saving array for jreviews_listing_totals table
$data['Totals'] += array($reviewType . '_rating' => is_numeric($userRating) ? number_format($userRating, 4) : $userRating, $reviewType . '_rating_count' => $reviewCount, $reviewType . '_criteria_rating' => implode(',', $ratings), $reviewType . '_criteria_rating_count' => implode(',', $reviewCountForCriterion));
}
# if ($rows)
}
# foreach ( $reviewTypes as $reviewType )
// ready to update database!
# reviews exist (user or editor). delete listing row
if (empty($reviewsExist)) {
appLogMessage('*******Deleting listing totals for listing ID ' . $listing_id . ' extension ' . $extension, 'database');
# not using s2 db function since it will use the wrong table
$query = "\n DELETE FROM #__jreviews_listing_totals\n WHERE\n listing_id = {$listing_id}\n AND extension = '{$extension}'\n ";
$this->_db->setQuery($query);
//.........这里部分代码省略.........
示例12: validate
function validate(&$data, $fieldLocation, $Access)
{
if (!isset($data['Field'])) {
return;
}
$location = $fieldLocation == 'listing' ? 'content' : 'review';
$query = "\n SELECT \n groupid \n FROM \n #__jreviews_criteria \n WHERE \n id = " . (int) $data['Criteria']['id'];
$this->_db->setQuery($query);
$groupids = $this->_db->loadResult();
if ($groupids) {
appLogMessage("*********Validate fields", 'database');
# PaidListings integration to remove hidden fields from validation
$plan_fields = isset($data['Paid']) ? explode(",", Sanitize::getString($data['Paid'], 'fields')) : '';
!empty($plan_fields) and $plan_fields = "'" . implode("','", $plan_fields) . "'";
$queryData = array('conditions' => array('Field.groupid IN (' . $groupids . ')', 'Field.published = 1', "Field.location = '{$location}'"));
$plan_fields != '' and $queryData['conditions'][] = "Field.name IN (" . $plan_fields . ")";
$fields = $this->findAll($queryData);
if (!$fields) {
return;
}
$valid_fields = array();
$fieldLocation = inflector::camelize($fieldLocation);
foreach ($fields as $field) {
// Check validation only for displayed fields *access rights*
if (in_array($Access->gid, explode(",", $field['Field']['access']))) {
$value = Sanitize::getVar($data['Field'][$fieldLocation], $field['Field']['name'], '');
// $value = isset($data['Field'][$fieldLocation][$field['Field']['name']]) ? $data['Field'][$fieldLocation][$field['Field']['name']] : '';
$label = sprintf(__t("You must fill in a valid value for %s.", true), $field['Field']['title']);
$name = $field['Field']['name'];
$type = $field['Field']['type'];
$required = $field['Field']['required'];
$valid_fields[] = $field['Field'];
$regex = '';
if (!isset($field['Field']['_params']['valid_regex'])) {
switch ($field['Field']['type']) {
case 'integer':
$regex = "^[0-9]+\$";
break;
case 'decimal':
$regex = "^(\\.[0-9]+|[0-9]+(\\.[0-9]*)?)\$";
break;
case 'website':
$regex = "^(ftp|http|https)+(:\\/\\/)+[a-z0-9_-]+\\.+[a-z0-9_-]";
break;
case 'email':
$regex = ".+@.*";
break;
default:
$regex = '';
break;
}
} elseif ($type != 'date') {
$regex = $field['Field']['_params']['valid_regex'];
}
if (!is_array($value)) {
$value = array($value);
} elseif ($type == 'selectmultiple' && is_array($value[0])) {
$data['Field'][$fieldLocation][$field['Field']['name']] = $data['Field'][$fieldLocation][$field['Field']['name']][0];
$value = $value[0];
}
$value = trim(implode(',', $value));
$this->validateInput($value, $name, $type, $label, $required, $regex);
}
}
return $valid_fields;
}
}
示例13: plgAfterSave
//.........这里部分代码省略.........
}
$mail->AddAddress(trim($listing['ListingUser']['email']));
$subject = isset($model->data['insertid']) ? sprintf(__t("New review: %s", true), $entry_title) : sprintf(__t("Edited review: %s", true), $entry_title);
$message = $this->c->render('email_templates', 'owner_review_notification');
$mail->Subject = $subject;
$mail->Body = $message;
if (!$mail->Send()) {
appLogMessage(array("Listing owner review message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
}
}
break;
# Notification for new owner replies to user reviews
# Notification for new owner replies to user reviews
case 'OwnerReply':
if ($this->c->Config->notify_owner_reply) {
# Process configuration emails
if ($this->c->Config->notify_owner_reply_emails == '') {
$mail->AddAddress($configMailFrom);
} else {
$recipient = explode("\n", $this->c->Config->notify_owner_reply_emails);
foreach ($recipient as $to) {
if (trim($to) != '') {
$mail->AddAddress(trim($to));
}
}
}
# Get review data
$this->c->Review->runProcessRatings = false;
$review = $this->c->Review->findRow(array('conditions' => array('Review.id = ' . (int) $model->data['OwnerReply']['id'])));
$extension = $review['Review']['extension'];
# Load jReviewsEverywhere extension model
$name = 'everywhere_' . $extension;
App::import('Model', $name, 'jreviews');
$class_name = inflector::camelize('everywhere_' . $extension) . 'Model';
$EverywhereListingModel = new $class_name();
# Get the listing title based on the extension being reviewed
$listing = $EverywhereListingModel->findRow(array('conditions' => array("Listing.{$EverywhereListingModel->realKey} = " . $review['Review']['listing_id'])));
$subject = sprintf(__t("Owner review reply submitted for listing %s", true), $listing['Listing']['title']);
$this->c->autoRender = false;
$this->c->set(array('User' => $this->c->_user, 'reply' => $model->data, 'review' => $review, 'listing' => $listing));
$message = $this->c->render('email_templates', 'admin_owner_reply_notification');
$mail->Subject = $subject;
$mail->Body = $message;
if (!$mail->Send() && _MVC_DEBUG_ERR) {
appLogMessage(array("Owner reply message was not sent.", "Mailer error: " . $mail->ErrorInfo), 'notifications');
}
}
break;
# Notification for new review reports
# Notification for new review reports
case 'Report':
if ($this->c->Config->notify_report) {
# Process configuration emails
if ($this->c->Config->notify_review_emails == '') {
$mail->AddAddress($configMailFrom);
} else {
$recipient = explode("\n", $this->c->Config->notify_review_emails);
foreach ($recipient as $to) {
if (trim($to) != '') {
$mail->AddAddress(trim($to));
}
}
}
# Get review data
$this->c->Review->runProcessRatings = false;
$review = $this->c->Review->findRow(array('conditions' => array('Review.id = ' . (int) $model->data['Report']['review_id'])), array());
示例14: replace
function replace($table, $alias, &$data, $keyName = null)
{
$fmtsql = "REPLACE INTO {$table} ( %s ) VALUES ( %s ) ";
$alias = inflector::camelize($alias);
$fields = array();
foreach ($data[$alias] as $k => $v) {
if (is_array($v) or is_object($v) or $v === NULL or $k[0] == '_') {
continue;
}
$fields[] = "`{$k}`";
$values[] = $this->Quote($v);
}
if (!isset($fields)) {
die('class database method insertObject - no fields');
}
$this->_db->setQuery(sprintf($fmtsql, implode(",", $fields), implode(",", $values)));
$replace = $this->_db->query();
$message[] = '*********' . get_class($this) . ' | Replace';
$message[] = $this->_db->getQuery();
$message[] = $this->_db->getErrorMsg();
appLogMessage($message, 'database');
if (!$replace) {
return false;
}
$id = $this->_db->insertid();
if ($keyName && $id) {
$data[$alias][$keyName] = $id;
}
return true;
}
示例15: _getListingEverywhere
function _getListingEverywhere($listing_id, $extension)
{
if (isset($this->c->viewVars['listing_' . $extension])) {
$listing = $this->c->viewVars['listing_' . $extension];
} else {
// Automagically load and initialize Everywhere Model
App::import('Model', 'everywhere_' . $extension, 'jreviews');
$class_name = inflector::camelize('everywhere_' . $extension) . 'Model';
if (class_exists($class_name)) {
$ListingModel = new $class_name();
$listing = $ListingModel->findRow(array('conditions' => array('Listing.' . $ListingModel->realKey . ' = ' . $listing_id)));
$this->c->set('listing_' . $extension, $listing);
}
}
return $listing;
}