protected function initialize() { dm::enableMailer(); $this->values = array(); $this->isRendered = false; $this->message = Swift_Message::newInstance(); }
/** * @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); } }
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; }
/** * 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; }
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')); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
/** * 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()); }
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'))); }
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); } }
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; }
/** * Get the current context * @return dmContext */ public function getContext() { if (null === $this->context) { if (!dmContext::hasInstance()) { $this->logSection('Diem Extended', sprintf('Loading %s...', get_class($this->configuration))); dm::createContext($this->configuration); } $this->context = dmContext::getInstance(); $this->context->get('filesystem')->setFormatter($this->formatter); } return $this->context; }
public function checkSlug($validator, $values) { if (!empty($values['slug'])) { $values['slug'] = dmString::urlize($values['slug'], true); $existingPageName = dmDb::query('DmPageTranslation t')->where('t.lang = ? AND t.slug = ?', array($this->object->lang, $values['slug']))->select('t.name')->fetchValue(); if ($existingPageName) { $error = new sfValidatorError($validator, dm::getI18n()->__('The page "%1%" uses this slug', array('%1%' => $existingPageName))); // throw an error bound to the password field throw new sfValidatorErrorSchema($validator, array('slug' => $error)); } } return $values; }
public function checkModuleAction($validator, $values) { if (!empty($values['module']) && !empty($values['action'])) { foreach (array('module', 'action') as $key) { $values[$key] = dmString::modulize(str_replace('-', '_', dmString::slugify(dmString::underscore($values[$key])))); } $existingPage = dmDb::query('DmPage p')->where('p.module = ? AND p.action = ? and p.record_id = ? AND p.id != ?', array($values['module'], $values['action'], $this->object->record_id, $this->object->id))->fetchRecord(); if ($existingPage) { $error = new sfValidatorError($validator, dm::getI18n()->__('The page "%1%" uses this module.action', array('%1%' => $existingPage->name))); // throw an error bound to the password field throw new sfValidatorErrorSchema($validator, array('action' => $error)); } } return $values; }
protected function sortZones(array $zoneList) { $zones = array(); foreach ($zoneList as $position => $zoneId) { $zones[$zoneId] = $position + 1; } try { dmDb::table('DmZone')->doSort($zones); } catch (Exception $e) { if ($this->getUser()->can('system')) { throw $e; } $this->getUser()->logError(dm::getI18n()->__('A problem occured when sorting the items')); } }
protected function generateRow(myDoctrineRecord $record) { $row = array(); foreach ($this->fields as $field => $fieldName) { try { $cell = $this->generateCell($field, $record); } catch (Exception $e) { $cell = dm::getI18n()->__('Error'); if (sfConfig::get('sf_debug')) { throw $e; $cell .= ' ' . $e->getMessage(); } } $row[] = $cell; } return $row; }
protected function getDiagramImage($appName) { $dependencyDiagramImage = sprintf('dependency_diagram_%s_%s.png', $appName, time()); $dependencyDiagramImageFullPath = dmOs::join(sfConfig::get('sf_web_dir'), 'cache', $dependencyDiagramImage); $dotFile = tempnam(sys_get_temp_dir(), 'dm_dependency_'); if (!$this->context->getFilesystem()->mkdir(dirname($dependencyDiagramImageFullPath))) { throw new dmException(sprintf('Can not mkdir %s', $dependencyDiagramImageFullPath)); } $configFiles = array(dmOs::join(sfConfig::get('dm_core_dir'), 'config/dm/services.yml'), dmOs::join(dm::getDir(), sprintf('dm%sPlugin/config/dm/services.yml', dmString::camelize($appName)))); $projectFile = dmOs::join(sfConfig::get('sf_config_dir'), 'dm/services.yml'); if (file_exists($projectFile)) { $configFiles[] = $projectFile; } $appFile = dmOs::join(sfConfig::get('sf_apps_dir'), $appName, 'config/dm/services.yml'); if (file_exists($appFile)) { $configFiles[] = $appFile; } $sc = new sfServiceContainerBuilder(); $loader = new sfServiceContainerLoaderFileYaml($sc); $loader->load($configFiles); $sc->setService('dispatcher', $this->context->getEventDispatcher()); $sc->setService('user', $this->context->getUser()); $sc->setService('response', $this->context->getResponse()); $sc->setService('i18n', $this->getI18n()); $sc->setService('routing', $this->context->getRouting()); $sc->setService('config_cache', $this->context->getConfigCache()); $sc->setService('controller', $this->context->getController()); $sc->setService('logger', $this->context->getLogger()); $sc->setService('module_manager', $this->context->getModuleManager()); $sc->setService('context', $this->context); $sc->setService('doctrine_manager', Doctrine_Manager::getInstance()); $dumper = new dmServiceContainerDumperGraphviz($sc); $dumper->enableDispatcherLinks($this->withDispatcherLinks); file_put_contents($dotFile, $dumper->dump(array('graph' => array('overlap' => 'false', 'splines' => 'true', 'epsilon' => '0.5', 'maxiter' => '30000', 'concentrate' => 'false', 'bgcolor' => 'transparent', 'ratio' => 'fill', 'size' => '25,12'), 'node' => array('fontsize' => 20, 'fontname' => 'Arial', 'shape' => 'Mrecord'), 'edge' => array('fontsize' => 9, 'fontname' => 'Arial', 'color' => 'grey', 'arrowhead' => 'open', 'arrowsize' => 1), 'node.instance' => array('fillcolor' => '#ffffff', 'style' => 'filled', 'shape' => 'component'), 'node.definition' => array('fillcolor' => 'transparent'), 'node.missing' => array('fillcolor' => '#ffaaaa', 'style' => 'filled', 'shape' => 'record')))); $filesystem = $this->context->getFileSystem(); //$return = $filesystem->exec(sprintf('dot -Tpng %s > %s', $dotFile, $dependencyDiagramImageFullPath)); //$return = $filesystem->exec(sprintf('twopi -Granksep=5 -Tpng %s > %s', $dotFile, $dependencyDiagramImageFullPath)); $return = $filesystem->exec(sprintf('neato -Tpng %s > %s', $dotFile, $dependencyDiagramImageFullPath)); unlink($dotFile); if (!$return) { $this->getUser()->logError(sprintf('Diem can not generate the %s dependency diagram. Probably graphviz is not installed on the server.', $appName), false); $this->getUser()->logAlert($filesystem->getLastExec('command') . "\n" . $filesystem->getLastExec('output'), false); } return '/cache/' . $dependencyDiagramImage; }
public function executeSaveSortReferers(sfWebRequest $request) { $this->forward404Unless($module = $this->context->getModuleManager()->getModuleOrNull($request->getParameter('dm_module'))); $this->forward404Unless($refererModule = $this->context->getModuleManager()->getModuleOrNull($request->getParameter('dm_referer_module'))); $elements = $request->getParameter('dm_sort_element'); $currentPosition = 1; foreach ($elements as $elementId => $position) { $elements[$elementId] = $currentPosition++; } try { $refererModule->getTable()->doSort($elements); } catch (Exception $e) { if ($this->getUser()->can('system')) { throw $e; } $this->getUser()->logError(dm::getI18n()->__('A problem occured when sorting the items'), array(), true); } $this->getUser()->logInfo(dm::getI18n()->__('The items have been sorted successfully'), array(), true); return $this->redirectBack(); }
protected function testUrl($url, $expectedStatusCode = 200) { $nbRedirects = 0; $this->startCounter($url); dm::resetStartTime(); $this->browser->get($url); while (in_array($this->browser->getResponse()->getStatusCode(), array(301, 302))) { $this->browser->with('response')->begin()->isRedirected()->end()->followRedirect(); $nbRedirects++; if ($nbRedirects > $this->options['maxRedirections']) { $this->browser->info('Too many redirections'); break; } } $this->stopCounter(); $this->browser->with('response')->begin()->isStatusCode($expectedStatusCode)->end(); if ($this->options['validate']) { $this->browser->with('response')->begin()->isValid()->end(); } }
protected function getConfigPathPriority($configPath) { // application configuration if (0 === strpos($configPath, sfConfig::get('sf_apps_dir'))) { return 6; } elseif (0 === strpos($configPath, sfConfig::get('sf_root_dir') . '/config')) { return 5; } elseif (0 === strpos($configPath, sfConfig::get('sf_plugins_dir'))) { return 4; } elseif (0 === strpos($configPath, sfConfig::get('dm_core_dir') . '/plugins')) { return 3; } elseif (0 === strpos($configPath, sfConfig::get('dm_core_dir'))) { return 1; } elseif (0 === strpos($configPath, sfConfig::get('sf_symfony_lib_dir'))) { return 0; } elseif (0 === strpos($configPath, dm::getDir())) { return 2; } //others ( ? ) return 4; }
public function render($name, $value = null, $attributes = array(), $errors = array()) { dm::getResponse()->addJavascript('lib.ui-datepicker'); if ('en' !== dm::getUser()->getCulture()) { dm::getResponse()->addJavascript('lib.ui-i18n'); } dm::getResponse()->addStylesheet('lib.ui-datepicker'); if ($value && strtotime($value)) { // convert value to an array $default = array('year' => null, 'month' => null, 'day' => null); $value = (string) $value == (string) (int) $value ? (int) $value : strtotime($value); if (false === $value) { $value = $default; } else { $value = array('year' => date('Y', $value), 'month' => date('n', $value), 'day' => date('j', $value)); } $formattedValue = strtr($this->getOption('format'), array('%year%' => sprintf('%04d', $value['year']), '%month%' => sprintf('%02d', $value['month']), '%day%' => sprintf('%02d', $value['day']))); } else { $formattedValue = $value; } //$formattedValue = dm::getI18n()->getDateForCulture(strtotime($value)); return $this->renderTag('input', array('name' => $name, 'size' => 10, 'id' => $this->generateId($name), 'class' => 'datepicker_me', 'value' => $formattedValue)); }
<?php require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php'; $helper = new dmUnitTestHelper(); $helper->boot('front'); $t = new lime_test(47); dm::loadHelpers(array('Dm')); sfConfig::set('sf_no_script_name', false); dmDb::table('DmPage')->checkBasicPages(); $sc = $helper->get('service_container'); $sc->mergeParameter('link_tag_record.options', array('current_span' => false))->mergeParameter('link_tag_page.options', array('current_span' => false)); $t->diag('link current_span is false'); $home = dmDb::table('DmPage')->getTree()->fetchRoot(); $helper->get('context')->setPage($home); $t->diag($home->name . ' is the current page'); $testPage = dmDb::create('DmPage', array('module' => 'main', 'action' => 'test' . dmString::random(12), 'name' => 'I am a root child', 'slug' => dmString::random())); $testPage->Node->insertAsLastChildOf($home); $scriptName = $helper->get('request')->getScriptName(); $t->diag('Current cli script name = ' . $scriptName); $t->is((string) _link('http://c2.com/cgi/wiki?DontRepeatYourself')->text('DRY'), $expected = '<a class="link" href="http://c2.com/cgi/wiki?DontRepeatYourself">DRY</a>', $expected); $t->like(£link()->render(), '|<a class="link dm_current|', '£link() has class dm_current'); $t->like(£link()->set('current_class', 'my_current')->render(), '|<a class="link my_current|', '£link() has class my_current'); $t->is((string) £link($home), (string) £link(), '£link($home) is £link()'); $t->is((string) £link('@homepage'), (string) £link($home), '£link("@homepage") is £link()'); $t->is((string) £link('main/root'), (string) £link($home), '£link("main/root") is £link()'); $t->is(£link()->getHref(), $scriptName, 'root href is ' . $scriptName); $t->is(£link()->getText(), $home->name, 'root link text is ' . $home->name); $expected = $helper->get('controller')->genUrl('dmAuth/signin'); $t->is(£link('+/dmAuth/signin')->getHref(), $expected, '+/dmAuth/signin href is ' . $expected); $rootLink = sprintf('<a class="%s" href="%s">%s</a>', 'link dm_current', $scriptName, $home->name); $t->is((string) £link(), $rootLink, 'root link is ' . $rootLink);
<?php require_once dirname(__FILE__) . '/includes/system/config.php'; // classes $dbInfo = new dbInfo(); $dbInfo->setHost('localhost'); $dbInfo->setUser('www-data'); $dbInfo->setPass('W3Wd@ta'); $dbInfo->setName('message'); $dm = new dm(false); $dm->connectDb($dbInfo); $dm->setVars('Message From Heaven', 'http://stoddart.message/', '/usr/local/www/data/message/'); $session = $dm->session(); $dm->setPaypalUser('sdk-three_api1.sdk.com'); // test = sdk-three_api1.sdk.com, live = ic3000_api1.q.com $dm->setPaypalPwd('QFZCWN5HZM8VBG7Q'); // test = QFZCWN5HZM8VBG7Q, live = HM9HWZ6C8MGM5JPR $dm->setPaypalSignature('A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU'); // test = A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU, live = Afzwki5kM8uclaP2ELeT59viD7-cAiKF71gyXndwl5alQmTaz-q5geM9 $dm->setPaypalMode('test'); // 'test' or 'live'
<?php require_once realpath(dirname(__FILE__) . '/../../../config/ProjectConfiguration.class.php'); require_once dm::getDir() . '/dmCorePlugin/lib/test/dmAdminFunctionalCoverageTest.php'; $config = array('login' => true, 'username' => 'admin', 'validate' => false, 'debug' => true, 'env' => 'prod'); $test = new dmAdminFunctionalCoverageTest($config); $test->run();
<?php $config = getcwd() . '/config/ProjectConfiguration.class.php'; require_once $config; require_once dm::getDir() . '/dmCorePlugin/test/unit/helper/dmUnitTestHelper.php'; $helper = new dmUnitTestHelper(); $helper->boot('front'); $t = new lime_test(50); dm::loadHelpers(array('Dm', 'I18N')); $menu = $helper->get('menu')->name('Test Menu'); $root1 = $menu->getChild('Root 1'); $root1->addChild('Child 1'); $last = $root1->addChild('Child 2'); $root2 = $menu->getChild('Root 2'); $child1 = $root2->addChild('Child 1'); $child2 = $child1->addChild('Child 2'); $t->is($root1->getLevel(), 0, 'Test root level is 0'); $t->is($root2->getLevel(), 0, 'Test root level is 0'); $t->is($child1->getLevel(), 1, 'Test level is 1'); $t->is($child2->getLevel(), 2, 'Test level is 2'); $t->is($child2->getPathAsString(), 'Test Menu > Root 2 > Child 1 > Child 2', 'Test getPathAsString()'); $t->is(get_class($root1), get_class($menu), 'Test children are created as same class as parent'); // array access $t->is($menu['Root 1']['Child 1']->getName(), 'Child 1', 'Test name()'); // countable $t->is(count($menu), $menu->count(), 'Test sfSympalMenu Countable interface'); $t->is(count($root1), 2, 'Test sfSympalMenu Countable interface'); $count = 0; foreach ($root1 as $key => $value) { $count++; $t->is($key, 'Child ' . $count, 'Test iteratable');
<?php require_once dirname(__FILE__) . '/includes/system/config.php'; // classes $dbInfo = new dbInfo(); $dbInfo->setHost('localhost'); $dbInfo->setUser('www-data'); $dbInfo->setPass('W3Wd@ta'); $dbInfo->setName('jcr_2010'); $dm = new dm(false); $dm->connectDb($dbInfo); $dm->setVars('2010 Rankings', 'http://stoddart.comp_rankings/2010/', '/usr/local/www/data/comp_rankings/2010/');