本文整理匯總了PHP中dmString::decode方法的典型用法代碼示例。如果您正苦於以下問題:PHP dmString::decode方法的具體用法?PHP dmString::decode怎麽用?PHP dmString::decode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dmString
的用法示例。
在下文中一共展示了dmString::decode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: executeRate
public function executeRate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod('POST'));
list($class, $id) = dmString::decode($request->getParameter('hash'));
$this->forward404Unless($table = dmDb::table($class));
$this->forward404Unless($record = $table->find($id));
$this->forward404Unless($table->hasTemplate('DmRatable'));
$template = $table->getTemplate('DmRatable');
$options = $template->getOptions();
$value = (int) $request->getParameter('value');
$this->forward404Unless($value >= 0 && $value <= $options['max_rate']);
$rate = array('rate' => $value);
if ($options['user']) {
$this->forward404Unless($this->getUser()->isAuthenticated());
$rate['dm_user_id'] = $this->getUser()->getUserId();
} else {
$rate['session_id'] = session_id();
}
if ($value) {
$record->addRate($rate);
$message = $this->getService('i18n')->__('Rating saved (%rate%)', array('%rate%' => $value));
} else {
$record->cancelRate($rate);
$message = $this->getService('i18n')->__('Rating removed');
}
return $this->renderComponent('dmRatable', 'rating', array('record' => $record, 'message' => $message));
}