本文整理汇总了PHP中dm类的典型用法代码示例。如果您正苦于以下问题:PHP dm类的具体用法?PHP dm怎么用?PHP dm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了dm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
protected function initialize()
{
dm::enableMailer();
$this->values = array();
$this->isRendered = false;
$this->message = Swift_Message::newInstance();
}
示例2: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
parent::execute($arguments, $options);
$projectWebPath = sfConfig::get('sf_web_dir');
$filesystem = new dmFilesystem($this->dispatcher, $this->formatter);
foreach (array('dmAdminPlugin', 'dmFrontPlugin') as $plugin) {
$this->logSection('plugin', 'Configuring plugin - ' . $plugin);
$this->installPluginAssets($plugin, dm::getDir() . '/' . $plugin);
}
// remove useless doctrine assets
if (is_readable($doctrineAssetPath = dmOs::join($projectWebPath, 'sfDoctrinePlugin'))) {
if (!is_link($doctrineAssetPath)) {
$filesystem->deleteDirContent($doctrineAssetPath);
}
$filesystem->remove($doctrineAssetPath);
}
// remove web cache dir
$webCacheDir = sfConfig::get('sf_web_dir') . '/cache';
if (is_link($webCacheDir)) {
$filesystem->remove($webCacheDir);
}
// create web cache dir
$filesystem->mkdir($webCacheDir);
if (!file_exists(dmOs::join($projectWebPath, 'sf'))) {
$filesystem->relativeSymlink(realpath(sfConfig::get('sf_symfony_lib_dir') . '/../data/web/sf'), dmOs::join($projectWebPath, 'sf'), true);
}
}
示例3: executeFormWidget
public function executeFormWidget(dmWebRequest $request)
{
$form = new OrderForm();
if ($request->hasParameter($form->getName()) && $form->bindAndValid($request)) {
$order = $form->save();
$order->setUid(md5(rand(1111, 9999) . time()));
$order->save();
// link order details
$this->shopping_cart = $shopping_cart = $this->getUser()->getShoppingCart();
$this->items = $shopping_cart->getItems();
foreach ($shopping_cart->getItems() as $i => $item) {
$od = new OrderDetail();
$od->fromArray(array('product_id' => $item->getId(), 'order_id' => $order->id, 'quantity' => $item->getQuantity(), 'price' => $item->getPrice()));
$od->save();
}
if (sfConfig::get('app_send_order', false)) {
dm::enableMailer();
//send mail
$message = $this->getMailer()->compose($_from = dmConfig::get('orderEmail'), $_to = array($order->email, dmConfig::get('orderEmail')), $_subj = '[' . dmConfig::get('siteName') . '] thanks for order');
$message->setBody($this->getPartial('order/mailOrder', array('order' => $order, 'companyName' => dmConfig::get('companyName'), 'companyPhone' => dmConfig::get('companyPhone'), 'siteUrl' => dmConfig::get('siteUrl'), 'siteName' => dmConfig::get('siteName'))));
$message->setContentType('text/html');
$this->getMailer()->send($message);
}
// if send order
// clear cart now
$shopping_cart->clear();
//redirect to order info
$this->redirect($this->getHelper()->link('main/ordershow?uid=' . $order->uid)->getHref());
//$this->redirectBack();
}
$this->forms['Order'] = $form;
}
示例4: getContext
/**
* Diem override:
* sfContext is hardcoded in symfony unit tests.
* Replace it with dmContext.
*
* @see sfBrowser
*/
public function getContext($forceReload = false)
{
if (null === $this->context || $forceReload) {
$isContextEmpty = null === $this->context;
$context = $isContextEmpty ? sfContext::getInstance() : $this->context;
// create configuration
$currentConfiguration = $context->getConfiguration();
$configuration = ProjectConfiguration::getApplicationConfiguration($currentConfiguration->getApplication(), $currentConfiguration->getEnvironment(), $currentConfiguration->isDebug());
// connect listeners
$configuration->getEventDispatcher()->connect('application.throw_exception', array($this, 'listenToException'));
foreach ($this->listeners as $name => $listener) {
$configuration->getEventDispatcher()->connect($name, $listener);
}
// create context
$this->context = dm::createContext($configuration);
unset($currentConfiguration);
if (!$isContextEmpty) {
sfConfig::clear();
sfConfig::add($this->rawConfiguration);
} else {
$this->rawConfiguration = sfConfig::getAll();
}
}
return $this->context;
}
示例5: configure
public function configure(array $data)
{
$isXhr = $data['context']->getRequest()->isXmlHttpRequest();
$uri = $this->cleanUri(dmArray::get($data['server'], 'PATH_INFO', $data['server']['REQUEST_URI']));
$milliseconds = (microtime(true) - dm::getStartTime()) * 1000;
$this->data = array('time' => (string) $data['server']['REQUEST_TIME'], 'uri' => dmString::truncate($uri, 500), 'code' => (string) $data['context']->getResponse()->getStatusCode(), 'app' => (string) sfConfig::get('sf_app'), 'env' => (string) sfConfig::get('sf_environment'), 'ip' => (string) $data['server']['REMOTE_ADDR'], 'user_id' => (string) $data['context']->getUser()->getUserId(), 'user_agent' => dmString::truncate($isXhr ? '' : isset($data['server']['HTTP_USER_AGENT']) ? $data['server']['HTTP_USER_AGENT'] : '', 500), 'xhr' => (int) $isXhr, 'mem' => (string) memory_get_peak_usage(true), 'timer' => (string) sprintf('%.0f', $milliseconds), 'cache' => sfConfig::get('dm_internal_page_cached'));
}
示例6: setup
public function setup()
{
$this->setWidgets(array('username' => new sfWidgetFormFilterInput(), 'email' => new sfWidgetFormFilterInput(), 'algorithm' => new sfWidgetFormFilterInput(), 'salt' => new sfWidgetFormFilterInput(), 'password' => new sfWidgetFormFilterInput(), 'is_active' => new sfWidgetFormChoice(array('choices' => array('' => dm::getI18n()->__('yes or no', array(), 'dm'), 1 => dm::getI18n()->__('yes', array(), 'dm'), 0 => dm::getI18n()->__('no', array(), 'dm')))), 'is_super_admin' => new sfWidgetFormChoice(array('choices' => array('' => dm::getI18n()->__('yes or no', array(), 'dm'), 1 => dm::getI18n()->__('yes', array(), 'dm'), 0 => dm::getI18n()->__('no', array(), 'dm')))), 'last_login' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormInputText(array(), array("class" => "datepicker_me")), 'to_date' => new sfWidgetFormInputText(array(), array("class" => "datepicker_me")), 'with_empty' => true)), 'created_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormInputText(array(), array("class" => "datepicker_me")), 'to_date' => new sfWidgetFormInputText(array(), array("class" => "datepicker_me")), 'with_empty' => false)), 'updated_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormInputText(array(), array("class" => "datepicker_me")), 'to_date' => new sfWidgetFormInputText(array(), array("class" => "datepicker_me")), 'with_empty' => false)), 'groups_list' => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'DmGroup')), 'permissions_list' => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'DmPermission'))));
$this->setValidators(array('username' => new sfValidatorPass(array('required' => false)), 'email' => new sfValidatorPass(array('required' => false)), 'algorithm' => new sfValidatorPass(array('required' => false)), 'salt' => new sfValidatorPass(array('required' => false)), 'password' => new sfValidatorPass(array('required' => false)), 'is_active' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))), 'is_super_admin' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))), 'last_login' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))), 'created_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))), 'updated_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))), 'groups_list' => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmGroup', 'required' => false)), 'permissions_list' => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmPermission', 'required' => false))));
$this->widgetSchema->setNameFormat('dm_user_filters[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
$this->setupInheritance();
parent::setup();
}
示例7: setup
public function setup()
{
$this->setWidgets(array('title' => new sfWidgetFormFilterInput(), 'is_active' => new sfWidgetFormChoice(array('choices' => array('' => dm::getI18n()->__('yes or no', array(), 'dm'), 1 => dm::getI18n()->__('yes', array(), 'dm'), 0 => dm::getI18n()->__('no', array(), 'dm')))), 'created_by' => new sfWidgetFormDoctrineChoice(array('model' => 'DmUser', 'add_empty' => true)), 'updated_by' => new sfWidgetFormDoctrineChoice(array('model' => 'DmUser', 'add_empty' => true))));
$this->setValidators(array('title' => new sfValidatorPass(array('required' => false)), 'is_active' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))), 'created_by' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('CreatedBy'), 'column' => 'id')), 'updated_by' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('UpdatedBy'), 'column' => 'id'))));
$this->widgetSchema->setNameFormat('dm_test_domain_translation_filters[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
$this->setupInheritance();
parent::setup();
}
示例8: setup
public function setup()
{
$this->setWidgets(array('post_id' => new sfWidgetFormDoctrineChoice(array('model' => 'DmTestPost', 'add_empty' => true)), 'author' => new sfWidgetFormFilterInput(), 'body' => new sfWidgetFormFilterInput(), 'is_active' => new sfWidgetFormChoice(array('choices' => array('' => dm::getI18n()->__('yes or no', array(), 'dm'), 1 => dm::getI18n()->__('yes', array(), 'dm'), 0 => dm::getI18n()->__('no', array(), 'dm')))), 'created_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormInputText(array(), array("class" => "datepicker_me")), 'to_date' => new sfWidgetFormInputText(array(), array("class" => "datepicker_me")), 'with_empty' => false)), 'updated_at' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormInputText(array(), array("class" => "datepicker_me")), 'to_date' => new sfWidgetFormInputText(array(), array("class" => "datepicker_me")), 'with_empty' => false)), 'version' => new sfWidgetFormFilterInput()));
$this->setValidators(array('post_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Post'), 'column' => 'id')), 'author' => new sfValidatorPass(array('required' => false)), 'body' => new sfValidatorPass(array('required' => false)), 'is_active' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))), 'created_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))), 'updated_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))), 'version' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false)))));
$this->widgetSchema->setNameFormat('dm_test_comment_filters[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
$this->setupInheritance();
parent::setup();
}
示例9: setup
public function setup()
{
$this->setWidgets(array('title' => new sfWidgetFormFilterInput(), 'excerpt' => new sfWidgetFormFilterInput(), 'body' => new sfWidgetFormFilterInput(), 'url' => new sfWidgetFormFilterInput(), 'is_active' => new sfWidgetFormChoice(array('choices' => array('' => dm::getI18n()->__('yes or no', array(), 'dm'), 1 => dm::getI18n()->__('yes', array(), 'dm'), 0 => dm::getI18n()->__('no', array(), 'dm'))))));
$this->setValidators(array('title' => new sfValidatorPass(array('required' => false)), 'excerpt' => new sfValidatorPass(array('required' => false)), 'body' => new sfValidatorPass(array('required' => false)), 'url' => new sfValidatorPass(array('required' => false)), 'is_active' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0)))));
$this->widgetSchema->setNameFormat('dm_test_post_translation_version_filters[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
$this->setupInheritance();
parent::setup();
}
示例10: setup
public function setup()
{
$this->setWidgets(array('slug' => new sfWidgetFormFilterInput(), 'name' => new sfWidgetFormFilterInput(), 'title' => new sfWidgetFormFilterInput(), 'h1' => new sfWidgetFormFilterInput(), 'description' => new sfWidgetFormFilterInput(), 'keywords' => new sfWidgetFormFilterInput(), 'auto_mod' => new sfWidgetFormFilterInput(), 'is_active' => new sfWidgetFormChoice(array('choices' => array('' => dm::getI18n()->__('yes or no', array(), 'dm'), 1 => dm::getI18n()->__('yes', array(), 'dm'), 0 => dm::getI18n()->__('no', array(), 'dm')))), 'is_secure' => new sfWidgetFormChoice(array('choices' => array('' => dm::getI18n()->__('yes or no', array(), 'dm'), 1 => dm::getI18n()->__('yes', array(), 'dm'), 0 => dm::getI18n()->__('no', array(), 'dm')))), 'is_indexable' => new sfWidgetFormChoice(array('choices' => array('' => dm::getI18n()->__('yes or no', array(), 'dm'), 1 => dm::getI18n()->__('yes', array(), 'dm'), 0 => dm::getI18n()->__('no', array(), 'dm'))))));
$this->setValidators(array('slug' => new sfValidatorPass(array('required' => false)), 'name' => new sfValidatorPass(array('required' => false)), 'title' => new sfValidatorPass(array('required' => false)), 'h1' => new sfValidatorPass(array('required' => false)), 'description' => new sfValidatorPass(array('required' => false)), 'keywords' => new sfValidatorPass(array('required' => false)), 'auto_mod' => new sfValidatorPass(array('required' => false)), 'is_active' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))), 'is_secure' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))), 'is_indexable' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0)))));
$this->widgetSchema->setNameFormat('dm_page_translation_filters[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
$this->setupInheritance();
parent::setup();
}
示例11: setup
public function setup()
{
$this->setWidgets(array('name' => new sfWidgetFormFilterInput(), 'description' => new sfWidgetFormFilterInput(), 'media_id' => new sfWidgetFormDoctrineChoice(array('model' => 'DmMedia', 'add_empty' => true)), 'is_visible' => new sfWidgetFormChoice(array('choices' => array('' => dm::getI18n()->__('yes or no', array(), 'dm'), 1 => dm::getI18n()->__('yes', array(), 'dm'), 0 => dm::getI18n()->__('no', array(), 'dm'))))));
$this->setValidators(array('name' => new sfValidatorPass(array('required' => false)), 'description' => new sfValidatorPass(array('required' => false)), 'media_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Media'), 'column' => 'id')), 'is_visible' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0)))));
$this->widgetSchema->setNameFormat('dm_test_user_filters[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
$this->setupInheritance();
parent::setup();
}
示例12: configure
/**
* Configures the current validator.
*
* Available options:
*
* * date_format: A regular expression that dates must match
* * with_time: true if the validator must return a time, false otherwise
* * date_output: The format to use when returning a date (default to Y-m-d)
* * datetime_output: The format to use when returning a date with time (default to Y-m-d H:i:s)
* * date_format_error: The date format to use when displaying an error for a bad_format error (use date_format if not provided)
* * max: The maximum date allowed (as a timestamp)
* * min: The minimum date allowed (as a timestamp)
* * date_format_range_error: The date format to use when displaying an error for min/max (default to d/m/Y H:i:s)
*
* Available error codes:
*
* * bad_format
* * min
* * max
*
* @param array $options An array of options
* @param array $messages An array of error messages
*
* @see sfValidatorBase
*/
protected function configure($options = array(), $messages = array())
{
parent::configure($options, $messages);
$i18n = dm::getI18n();
$this->addMessage('bad_format', '"%value%" ' . $i18n->__('does not match the date format') . ' (%date_format%).');
$this->addMessage('max', $i18n->__('The date must be before') . ' %max%.');
$this->addMessage('min', $i18n->__('The date must be after') . ' %min%.');
// $this->addOption('date_format', $this->getDateFormat(dm::getUser()->getCulture()));
$this->addOption('context', dmContext::getInstance());
}
示例13: renderHead
protected function renderHead()
{
return sprintf('<html>
<head>
<title>Diem %s System Check</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<style type="text/css">%s</style>
</head>', DIEM_VERSION, file_get_contents(dmOs::join(dm::getDir(), 'dmCorePlugin/web/lib/blueprint/screen.css')) . file_get_contents(dmOs::join(dm::getDir(), 'dmCorePlugin/web/css/serverCheck.css')));
}
示例14: setDmPluginPaths
protected function setDmPluginPaths()
{
$baseDir = dm::getDir();
foreach (array('dmCorePlugin', 'dmAdminPlugin', 'dmFrontPlugin') as $rootPlugin) {
$this->setPluginPath($rootPlugin, $baseDir . '/' . $rootPlugin);
}
foreach (array('dmUserPlugin', 'dmAlternativeHelperPlugin', 'sfWebBrowserPlugin', 'sfImageTransformPlugin', 'sfFeed2Plugin', 'sfFormExtraPlugin') as $embeddedPlugin) {
$this->setPluginPath($embeddedPlugin, $baseDir . '/dmCorePlugin/plugins/' . $embeddedPlugin);
}
}
示例15: getContext
public function getContext()
{
if (null === $this->context) {
if (!dmContext::hasInstance()) {
$this->logSection('diem', sprintf('Loading %s...', get_class($this->configuration)));
dm::createContext($this->configuration);
}
$this->context = dmContext::getInstance();
}
return $this->context;
}