protected function createPageTranslations($pageId) { $cultures = $this->getOption('cultures'); $translationTable = dmDb::table('DmPageTranslation'); $existingCultures = $translationTable->createQuery('t')->where('t.id = ? ', $pageId)->andWhereIn('t.lang', $cultures)->select('t.lang')->fetchFlat(); // can not generate translations from nothing if (empty($existingCultures)) { return; } // calculate missing cultures for this page $missingCultures = array_diff($cultures, $existingCultures); // all translations exist if (empty($missingCultures)) { return; } if (in_array(sfConfig::get('sf_default_culture'), $existingCultures)) { $mainCulture = sfConfig::get('sf_default_culture'); } elseif (in_array(myDoctrineRecord::getDefaultCulture(), $existingCultures)) { $mainCulture = myDoctrineRecord::getDefaultCulture(); } else { $mainCulture = dmArray::first($existingCultures); } $mainTranslationArray = $translationTable->createQuery('t')->select('t.slug, t.name, t.title, t.h1, t.description, t.keywords, t.is_active')->where('t.id = ?', $pageId)->andWhere('t.lang = ?', $mainCulture)->limit(1)->fetchOne(array(), Doctrine_Core::HYDRATE_ARRAY); $missingTranslations = new myDoctrineCollection(dmDb::table('DmPageTranslation')); if ($this->getOption('activate_new_translations')) { $isActive = $mainTranslationArray['is_active']; } else { $isActive = false; } foreach ($missingCultures as $culture) { $missingTranslations->add($translationTable->create(array_merge($mainTranslationArray, array('lang' => $culture, 'is_active' => $isActive)))); } $missingTranslations->save(); }
protected function initialize(array $options) { $this->configure($options); if (!$this->themeNameExists($this->options['default'])) { $this->options['default'] = dmArray::first($this->getThemeNames()); } $this->themes = array(); }
public function configure() { $this->widgetSchema['media_id'] = new sfWidgetFormDoctrineChoice(array('model' => 'DmMedia', 'multiple' => true)); $this->validatorSchema['media_id'] = new sfValidatorDoctrineChoice(array('model' => 'DmMedia', 'multiple' => true)); $this->validatorSchema['media_link'] = new sfValidatorPass(); $this->validatorSchema['media_alt'] = new sfValidatorPass(); $this->validatorSchema['media_position'] = new sfValidatorPass(); $this->widgetSchema['width'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['width'] = new dmValidatorCssSize(array('required' => false)); $this->widgetSchema['height'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['height'] = new dmValidatorCssSize(array('required' => false)); $this->widgetSchema['cols'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['cols'] = new sfValidatorNumber(array('required' => false, 'min' => 1, 'max' => 20)); if (!$this->hasDefault('cols')) { $this->setDefault('cols', 3); } $this->widgetSchema['rows'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['rows'] = new sfValidatorNumber(array('required' => false, 'min' => 1, 'max' => 20)); if (!$this->hasDefault('rows')) { $this->setDefault('rows', 3); } $this->widgetSchema['margin'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['margin'] = new dmValidatorCssSize(array('required' => false)); $this->widgetSchema['big_width'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['big_width'] = new dmValidatorCssSize(array('required' => false)); $this->widgetSchema['big_height'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['big_height'] = new dmValidatorCssSize(array('required' => false)); $methods = $this->getService('i18n')->translateArray(self::$methods); $this->widgetSchema['method'] = new sfWidgetFormSelect(array('choices' => $methods)); $this->validatorSchema['method'] = new sfValidatorChoice(array('choices' => array_keys($methods))); if (!$this->getDefault('method')) { $this->setDefault('method', dmConfig::get('image_resize_method', 'center')); } $transitions = $this->getService('i18n')->translateArray(self::$transitions); $this->widgetSchema['transition'] = new sfWidgetFormSelect(array('choices' => $transitions)); $this->validatorSchema['transition'] = new sfValidatorChoice(array('choices' => array_keys($transitions))); if (!$this->getDefault('transition')) { $this->setDefault('transition', dmArray::first(array_keys($transitions))); } $this->widgetSchema['speed'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['speed'] = new sfValidatorNumber(array('required' => false, 'min' => 0, 'max' => 2000)); $this->widgetSchema['opacity'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['opacity'] = new sfValidatorNumber(array('required' => false, 'min' => 0, 'max' => 1)); $this->widgetSchema['config'] = new sfWidgetFormTextarea(array(), array('cols' => 15, 'rows' => 3)); $this->validatorSchema['config'] = new sfValidatorString(array('required' => false)); $this->widgetSchema['quality'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['quality'] = new sfValidatorInteger(array('required' => false, 'min' => 0, 'max' => 100)); if (!$this->getDefault('medias')) { $this->setDefault('medias', array()); } // $this->widgetSchema['background'] = new sfWidgetFormInputText(array(), array('size' =>7)); // $this->validatorSchema['background'] = new sfValidatorString(array( // 'required' => false // )); $this->validatorSchema['widget_width'] = new sfValidatorInteger(array('required' => false)); parent::configure(); }
public function executeChangeMaxPerPage(sfWebRequest $request) { $this->forward404Unless($module = $this->context->getModuleManager()->getModuleBySfName($sfModule = $request->getParameter('dm_module'))); if ($maxPerPage = $request->getParameter('max_per_page')) { $maxPerPages = sfConfig::get('dm_admin_max_per_page', array(10)); $maxPerPage = in_array($maxPerPage, $maxPerPages) ? $maxPerPage : dmArray::first($maxPerPages); $this->getUser()->setAttribute($sfModule . '.max_per_page', $maxPerPage, 'admin_module'); $this->getUser()->setAttribute($sfModule . '.page', 1, 'admin_module'); } return $this->redirectBack(); }
public function execute(array $onlyModules = array()) { if (empty($onlyModules)) { $onlyModules = $this->moduleManager->getProjectModules(); } elseif (is_string(dmArray::first($onlyModules))) { $onlyModules = $this->moduleManager->keysToModules($onlyModules); } $onlyModules = dmModuleManager::removeModulesChildren($onlyModules); $this->updateListPages(); $this->removeShowPages($onlyModules); $this->updateShowPages($onlyModules); }
public function configure() { /* * Record id */ $this->widgetSchema['recordId'] = new sfWidgetFormDoctrineChoice(array('model' => $this->dmModule->getModel(), 'add_empty' => $this->allowAutoRecordId() ? sprintf('(%s) %s', $this->__('contextual'), $this->getAutoRecord()->__toString()) : false)); $this->widgetSchema['recordId']->setLabel($this->getDmModule()->getName()); $this->validatorSchema['recordId'] = new sfValidatorDoctrineChoice(array('model' => $this->dmModule->getModel(), 'required' => !$this->allowAutoRecordId())); $this->setDefaults($this->getDefaultsFromLastUpdated()); if (!$this->allowAutoRecordId() && !$this->getDefault('recordId')) { $this->setDefault('recordId', dmArray::first(array_keys($this->widgetSchema['recordId']->getChoices()))); } parent::configure(); }
public function execute(array $onlyModules, $culture) { $this->setCulture($culture); $recordDefaultCulture = myDoctrineRecord::getDefaultCulture(); myDoctrineRecord::setDefaultCulture($this->culture); if (empty($onlyModules)) { $onlyModules = $this->moduleManager->getProjectModules(); } elseif (is_string(dmArray::first($onlyModules))) { $onlyModules = $this->moduleManager->keysToModules($onlyModules); } $onlyModules = dmModuleManager::removeModulesChildren($onlyModules); foreach ($onlyModules as $module) { $this->updateRecursive($module); } myDoctrineRecord::setDefaultCulture($recordDefaultCulture); }
protected function findPageAndCultureForAnotherCulture($slug) { $i18n = $this->serviceContainer->getService('i18n'); if (!$i18n->hasManyCultures()) { return false; } // search in all cultures $page = dmDb::query('DmPage p')->innerJoin('p.Translation t')->where('t.slug = ?', $slug)->fetchOne(); if (!$page) { return false; } // use the default culture if ($page->get('Translation')->contains(sfConfig::get('sf_default_culture'))) { $culture = sfConfig::get('sf_default_culture'); } else { $culture = dmArray::first(array_keys($page->get('Translation')->getData())); } return array($page, $culture); }
/** * @see sfProjectConfiguration */ public function initConfiguration() { parent::initConfiguration(); include $this->getConfigCache()->checkConfig('config/dm/config.yml'); /* * Replace sf default culture by first culture in dm cultures configuration */ sfConfig::set('sf_default_culture', dmArray::first(sfConfig::get('dm_i18n_cultures'))); /* * Symfony 1.3 registers sfAutoloadAgain on dev env. This causes huge performance issues. */ if ($this->isDebug()) { sfAutoloadAgain::getInstance()->unregister(); } /* * Now that we have the project config, we can configure the doctrine cache */ $this->configureDoctrineCache(Doctrine_Manager::getInstance()); }
public function preloadPagesForRecords($records) { if ($records instanceof Doctrine_Collection) { $records = $records->getData(); } foreach ($records as $index => $record) { if (!$record instanceof dmDoctrineRecord) { unset($records[$index]); } } if (!empty($records)) { if (($module = dmArray::first($records)->getDmModule()) && $module->hasPage()) { $ids = array(); foreach ($records as $record) { $ids[] = $record->get('id'); } $this->prepareRecordPageCache($module->getKey(), array_unique($ids)); } } }
public function configure() { $this->widgetSchema['media_id'] = new sfWidgetFormDoctrineChoice(array('model' => 'DmMedia', 'multiple' => true)); $this->validatorSchema['media_id'] = new sfValidatorDoctrineChoice(array('model' => 'DmMedia', 'multiple' => true)); $this->validatorSchema['media_link'] = new sfValidatorPass(); $this->validatorSchema['media_alt'] = new sfValidatorPass(); $this->validatorSchema['media_position'] = new sfValidatorPass(); $this->widgetSchema['width'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['width'] = new dmValidatorCssSize(array('required' => false)); $this->widgetSchema['height'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['height'] = new dmValidatorCssSize(array('required' => false)); $methods = $this->getService('i18n')->translateArray(self::$methods); $this->widgetSchema['method'] = new sfWidgetFormSelect(array('choices' => $methods)); $this->validatorSchema['method'] = new sfValidatorChoice(array('choices' => array_keys($methods))); if (!$this->getDefault('method')) { $this->setDefault('method', dmConfig::get('image_resize_method', 'center')); } $this->widgetSchema['show_pager'] = new sfWidgetFormInputCheckbox(); $this->validatorSchema['show_pager'] = new sfValidatorBoolean(); $animations = $this->getService('i18n')->translateArray(self::$animations); $this->widgetSchema['animation'] = new sfWidgetFormSelect(array('choices' => $animations)); $this->validatorSchema['animation'] = new sfValidatorChoice(array('choices' => array_keys($animations))); if (!$this->getDefault('animation')) { $this->setDefault('animation', dmArray::first(array_keys($animations))); } $this->widgetSchema['delay'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['delay'] = new sfValidatorNumber(array('required' => false, 'min' => 0, 'max' => 1000)); if (!$this->hasDefault('delay')) { $this->setDefault('delay', 3); } $this->widgetSchema['quality'] = new sfWidgetFormInputText(array(), array('size' => 5)); $this->validatorSchema['quality'] = new sfValidatorInteger(array('required' => false, 'min' => 0, 'max' => 100)); if (!$this->getDefault('medias')) { $this->setDefault('medias', array()); } $this->widgetSchema['background'] = new sfWidgetFormInputText(array(), array('size' => 7)); $this->validatorSchema['background'] = new sfValidatorString(array('required' => false)); $this->validatorSchema['widget_width'] = new sfValidatorInteger(array('required' => false)); parent::configure(); }
protected function loadSettings() { $array = array('site_name' => array('default_value' => dmString::humanize(dmProject::getKey()), 'description' => 'The site name', 'group_name' => 'site'), 'site_active' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Is the site ready for visitors ?', 'group_name' => 'site'), 'site_indexable' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Is the site ready for search engine crawlers ?', 'group_name' => 'site'), 'site_working_copy' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Is this site the current working copy ?', 'group_name' => 'site'), 'ga_key' => array('description' => 'The google analytics key without javascript stuff ( e.g. UA-9876614-1 )', 'group_name' => 'tracking', 'credentials' => 'google_analytics'), 'ga_token' => array('description' => 'Auth token gor Google Analytics, computed from password', 'group_name' => 'internal', 'credentials' => 'google_analytics'), 'gwt_key' => array('description' => 'The google webmaster tools filename without google and .html ( e.g. a913b555ba9b4f13 )', 'group_name' => 'tracking', 'credentials' => 'google_webmaster_tools'), 'xiti_code' => array('type' => 'textarea', 'description' => 'The xiti html code', 'group_name' => 'tracking', 'credentials' => 'xiti'), 'search_stop_words' => array('type' => 'textarea', 'description' => 'Words to exclude from searches (e.g. the, a, to )', 'group_name' => 'search engine', 'credentials' => 'search_engine'), 'base_urls' => array('type' => 'textarea', 'description' => 'Diem base urls for different applications/environments/cultures', 'group_name' => 'internal', 'credentials' => 'system'), 'image_resize_method' => array('type' => 'select', 'default_value' => 'center', 'description' => 'Default method when an image needs to be resized', 'params' => 'fit=Fit scale=Scale inflate=Inflate top=Top right=Right left=Left bottom=Bottom center=Center', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'image_resize_quality' => array('type' => 'number', 'default_value' => 95, 'description' => 'Jpeg default quality when generating thumbnails', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'link_external_blank' => array('type' => 'boolean', 'default_value' => 0, 'description' => 'Links to other domain get automatically a _blank target', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'link_current_span' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Links to current page are changed from <a> to <span>', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'link_use_page_title' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'Add an automatic title on link based on the target page title', 'group_name' => 'interface', 'credentials' => 'interface_settings'), 'title_prefix' => array('default_value' => '', 'description' => 'Append something at the beginning of all pages title', 'group_name' => 'seo', 'credentials' => 'manual_metas'), 'title_suffix' => array('default_value' => ' | ' . dmString::humanize(dmProject::getKey()), 'description' => 'Append something at the end of all pages title', 'group_name' => 'seo', 'credentials' => 'manual_metas'), 'smart_404' => array('type' => 'boolean', 'default_value' => 1, 'description' => 'When a page is not found, user is redirect to a similar page. The internal search index is used to find the best page for requested url.', 'group_name' => 'seo', 'credentials' => 'url_redirection')); $existingSettings = dmDb::query('DmSetting s INDEXBY s.name')->withI18n()->fetchRecords(); foreach ($array as $name => $config) { if (!isset($existingSettings[$name])) { $setting = new DmSetting(); $setting->set('name', $name); $setting->fromArray($config); $setting->save(); } elseif (!$existingSettings[$name]->hasCurrentTranslation()) { /* * Try to find an existing config from another culture */ $existing = dmDb::query('DmSettingTranslation s')->where('s.id = ?', $existingSettings[$name]->id)->limit(1)->fetchArray(); if ($existing = dmArray::first($existing)) { $config = $existing; unset($config['id'], $config['lang']); } $existingSettings[$name]->fromArray($config)->getCurrentTranslation()->save(); } } dmConfig::load(false); }
public function getFirstChild() { return dmArray::first($this->children); }
<?php require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php'; $helper = new dmUnitTestHelper(); $helper->boot(); $t = new lime_test(21); $t->diag('first'); $t->is_deeply(dmArray::first('alpha'), 'alpha', 'first parameter is not an array'); $t->is_deeply(dmArray::first(array()), null, 'empty source array'); $array = array('alpha', 'beta', 'gamma', 'delta'); $t->is_deeply(dmArray::first($array), 'alpha', 'first value'); $t->diag('firsts'); $t->is_deeply(dmArray::firsts('alpha', 2), 'alpha', 'first parameter is not an array'); $t->is_deeply(dmArray::firsts(array(), 2), null, 'empty source array'); $t->is_deeply(dmArray::firsts(array('alpha'), 2), array('alpha'), 'not enough values'); $array = array('alpha', 'beta', 'gamma', 'delta'); $t->is_deeply(dmArray::firsts($array, 2), array('alpha', 'beta'), 'first values'); $t->diag('get'); $t->is_deeply(dmArray::get('alpha', null, 'test'), 'test', 'first parameter is not an array'); $t->is_deeply(dmArray::get(array('alpha'), 0, 'test'), 'alpha', 'key exists'); $t->is_deeply(dmArray::get(array('alpha'), 1, 'test'), 'test', 'key not exists'); $t->is_deeply(dmArray::get(array(''), 0, 'test', false), '', 'empty value without default if empty'); $t->is_deeply(dmArray::get(array(''), 0, 'test', true), 'test', 'empty value with default if empty'); $t->is_deeply(dmArray::get(array('alpha'), 0, 'test', true), 'alpha', 'key exists with default if empty'); $t->diag('last'); $t->is_deeply(dmArray::last('alpha'), 'alpha', 'first parameter is not an array'); $t->is_deeply(dmArray::last(array()), null, 'empty source array'); $array = array('alpha', 'beta', 'gamma', 'delta'); $t->is_deeply(dmArray::last($array), 'delta', 'last value'); $t->diag('toHtmlCssClasses'); $classes = array('class1', '', ' class2', ' ', ' class3 ');
/** * Will return pk column name if table has only one pk, or null */ public function getPrimaryKey() { if (count($this->getPrimaryKeys()) === 1) { return dmArray::first($this->getPrimaryKeys()); } return null; }
protected function getData() { if (!($data = $this->getCache('data'))) { $data = array('date' => array(), 'timer' => array()); $requestLogEntries = $this->serviceContainer->getService('request_log')->getEntries(10000, array('hydrate' => false, 'keys' => array('time', 'timer', 'code', 'mem'))); $logDelta = dmArray::get(dmArray::first($requestLogEntries), 'time') - dmArray::get(dmArray::last($requestLogEntries), 'time'); $hours = $logDelta / 3600; if ($hours < 1) { throw new dmException('Not enough log entries'); } $stepFactor = $hours / 40; $step = round(60 * 60 * $stepFactor); $stepDate = $_SERVER['REQUEST_TIME'] - $step; $tmpTimes = array(); $tmpMems = array(); $tmpErrs = 0; $data = array('date' => array(), 'time' => array(), 'nbReq' => array(), 'nbErr' => array(), 'mem' => array()); if (count($requestLogEntries) < 50) { throw new dmException('Not enough log entries'); } foreach ($requestLogEntries as $userLogEntry) { $date = $userLogEntry['time']; $timer = $userLogEntry['timer']; $mem = $userLogEntry['mem']; $err = in_array($userLogEntry['code'], array('500', '404')); if ($date > $stepDate) { $tmpTimes[] = $timer; $tmpMems[] = $mem; $tmpErrs += $err; } else { $nb = count($tmpTimes); $trustableData = $nb >= 10; $data['date'][] = $stepDate; $data['nbReq'][] = $trustableData ? $nb / $stepFactor : ''; $data['nbErr'][] = $trustableData ? $tmpErrs / $stepFactor : ''; $data['time'][] = $trustableData ? array_sum($tmpTimes) / $nb : ''; $data['mem'][] = $trustableData ? array_sum($tmpMems) / $nb : ''; $stepDate -= $step; $tmpTimes = array($timer); $tmpMems = array($mem); $tmpErrs = $err; } } $nb = count($tmpTimes); $trustableData = $nb >= 5; $data['date'][] = $stepDate; $data['nbReq'][] = $nb / $stepFactor; $data['nbErr'][] = $tmpErrs / $stepFactor; $data['time'][] = $trustableData ? array_sum($tmpTimes) / $nb : ""; $data['mem'][] = $trustableData ? array_sum($tmpMems) / $nb : ""; foreach (array_keys($data) as $key) { $data[$key] = array_reverse($data[$key]); } foreach ($data['mem'] as $index => $value) { $data['nbReq'][$index] = $data['nbReq'][$index] / 60; $data['nbErr'][$index] = $data['nbErr'][$index] / 60; if ("" != $data['mem'][$index]) { $data['mem'][$index] = $value / (1024 * 1024); } if ($data['time'][$index] > 5000) { $data['time'][$index] = 5000; } } $events = $this->serviceContainer->getService('event_log')->getEntries(1000, array('filter' => array($this, 'filterEvent'), 'hydrate' => false)); $data['events'] = array(); foreach ($this->eventsFilter as $eventType) { $data['events'][$eventType] = array(); for ($it = 0, $itMax = count($data['date']); $it < $itMax; $it++) { $data['events'][$eventType][] = 0; } } $time = time(); foreach ($events as $event) { $eventType = $event['action'] . ' ' . $event['type']; $timeDelta = $time; $nearestTimeIndex = null; foreach ($data['date'] as $index => $time) { $eventTimeDelta = abs($time - $event['time']); if ($eventTimeDelta < $timeDelta) { $nearestTimeIndex = $index; $timeDelta = $eventTimeDelta; } } if ($timeDelta < $data['date'][1] - $data['date'][0]) { ++$data['events'][$eventType][$nearestTimeIndex]; } } unset($events); $this->setCache('data', $data); } return $data; }
protected static function debugger($var, $level = 1, $opt = array()) { $CR = "\n"; $die = $level > 2; $opt = dmString::toArray($opt); if (!sfConfig::get('sf_debug') && !dmArray::get($opt, "force")) { return; } $tag = dmArray::get($opt, "tag", "pre"); if (dmArray::get($opt, "to_string", false) && is_array($var)) { array_walk_recursive($var, create_function('&$val', 'if(is_object($val)) { if (method_exists($val, "toString")) { $val = get_class($val)." : ".$val->toString(); } elseif (method_exists($val, "__toString")) { $val = get_class($val)." : ".$val->__toString(); } }')); } elseif (is_array($var)) { array_walk_recursive($var, create_function('&$val', 'if(is_object($val)) { if (method_exists($val, "toDebug")) { $val = get_class($val)." : ".print_r($val->toDebug(), true); } elseif (method_exists($val, "toArray")) { $val = get_class($val)." : ".print_r($val->toArray(), true); } }')); } if (dmConfig::isCli()) { $debugString = print_r($var, true); $debugString = substr($debugString, 0, self::MAX_DEBUG_LENGTH); echo $debugString; if (strlen($debugString) > self::MAX_DEBUG_LENGTH) { echo "\n---TRUNCATED---\n"; } if ($die) { die; } } else { array_walk_recursive($var, create_function('&$val', 'if(is_string($val)) { $val = htmlspecialchars($val); }')); if (count($var) == 1) { $var = dmArray::first($var); } if (dmContext::hasInstance() && ($request = dm::getRequest())) { if ($request->isXmlHttpRequest()) { echo "\n<{$tag}>"; $debugString = print_r($var, true); echo substr($debugString, 0, self::MAX_DEBUG_LENGTH); if (strlen($debugString) > self::MAX_DEBUG_LENGTH) { echo "\n---TRUNCATED---\n"; } echo "</{$tag}>\n"; if ($die) { die; } return; } } ob_start(); if ($level > 1) { print '<br /><' . $tag . ' style="text-align: left; border: 1px solid #aaa; border-left-width: 10px; background-color: #f4F4F4; color: #000; margin: 3px; padding: 3px; font-size: 11px;">'; $debugString = print_r($var, true); echo substr($debugString, 0, self::MAX_DEBUG_LENGTH); if (strlen($debugString) > self::MAX_DEBUG_LENGTH) { echo "\n---TRUNCATED---\n"; } print "</{$tag}>"; } $buffer = ob_get_clean(); if ($level == 4) { ob_start(); echo '<pre>'; debug_print_backtrace(); echo '</pre>'; $dieMsg = ob_get_clean(); } else { $backtrace = debug_backtrace(); $dieMsg = str_replace(sfConfig::get("sf_root_dir"), "", dmArray::get($backtrace[1], 'file')) . " l." . dmArray::get($backtrace[1], 'line'); // $dieMsg = '<pre>'; // $dieMsg .= isset($backtrace[0]['file']) ? '> file : <b>'. // $backtrace[1]['file'] .'</b>'. $CR : ''; // $dieMsg .= isset($backtrace[0]['line']) ? '> line : <b>'. // $backtrace[1]['line'] .'</b>'. $CR : ''; // $dieMsg .= isset($backtrace[1]['class']) ? '> class : <b>'. // dmArray::get(dmArray::get($backtrace, 2, array()), 'class') .'</b>'. $CR : ''; // $dieMsg .= isset($backtrace[1]['function']) ? '> function : <b>'. // dmArray::get(dmArray::get($backtrace, 2, array()), 'function') .'</b>'. $CR : ''; // $dieMsg .= '</pre>'; } if ($level > 1) { print $buffer; if ($die) { die($dieMsg); } else { print $dieMsg; } } else { sfWebDebug::getInstance()->logShortMessage($buffer . $dieMsg); } } }