function sw_combine_debug() { if (ProjectConfiguration::getActive()->isDebug()) { $response = sfContext::getInstance()->getResponse(); echo "<!-- DEBUG MODE - \nCombined files : \n" . var_export($response->getCombinedAssets(), 1) . "\n -->\n"; } }
/** * __construct * * @param string $options * @return void */ public function __construct(array $options = array()) { $dispatcher = ProjectConfiguration::getActive()->getEventDispatcher(); $dispatcher->connect('commentable.add_commentable_class', array($this, 'getCommentables')); $options['generatePath'] = sfConfig::get('sf_lib_dir') . '/model/doctrine/sfCommentsPlugin'; $this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options); }
public function getCommentables() { $dispatcher = ProjectConfiguration::getActive()->getEventDispatcher(); $event = new sfEvent($this, 'commentable.add_commentable_class'); $dispatcher->notify($event); $commentables = $event->getReturnValue(); return $commentables ? $commentables : array(); }
public function preExecute() { $this->isUserAdmin = $this->checkCredentials(); $this->tabs = sfPlop::get('sf_plop_dashboard_settings_tabs'); $this->sub = $this->getRequest()->getParameter('sub'); ProjectConfiguration::getActive()->LoadHelpers(array('I18N')); $this->getResponse()->setTitle(sfPlop::setMetaTitle(__('Dashboard', '', 'plopAdmin'))); }
public function configure() { // Cookie settings for increased security ini_set('session.use_only_cookies', "1"); ini_set('session.cookie_httponly', "1"); ProjectConfiguration::getActive()->loadHelpers(array('I18N', 'OrangeDate', 'Orange', 'Url')); sfWidgetFormSchema::setDefaultFormFormatterName('Default'); }
/** * Log a message. * * @param mixed $subject * @param string $message * @param string $priority */ public static function logMessage($subject, $message, $priority = 'info') { if (class_exists('ProjectConfiguration', false)) { ProjectConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($subject, 'application.log', array($message, 'priority' => constant('sfLogger::' . strtoupper($priority))))); } else { $message = sprintf('{%s} %s', is_object($subject) ? get_class($subject) : $subject, $message); sfContext::getInstance()->getLogger()->log($message, constant('SF_LOG_' . strtoupper($priority))); } }
/** * Can be used inside a magic __call method to allow for a class to be extended * * This method will throw a class_name.method_not_found event, * where class_name is the "tableized" class name. * * @example * public function __call($method, $arguments) * { * return sfSympalExtendClass::extendEvent($this, $method, $arguments); * } * * @param mixed $subject Instance of the class being extended * @param string $method The current method being called * @param array $arguments The arguments being passed to the above methid */ public static function extendEvent($subject, $method, $arguments) { $name = sfInflector::tableize(get_class($subject)); $event = ProjectConfiguration::getActive()->getEventDispatcher()->notifyUntil(new sfEvent($subject, $name . '.method_not_found', array('method' => $method, 'arguments' => $arguments))); if (!$event->isProcessed()) { throw new sfException(sprintf('Call to undefined method %s::%s.', get_class($subject), $method)); } return $event->getReturnValue(); }
public function execute($request) { $this->form = new sfForm(); if (!$this->context->user->hasCredential('administrator')) { QubitAcl::forwardUnauthorized(); } $criteria = new Criteria(); $criteria->add(QubitSetting::NAME, 'plugins'); if (1 == count($query = QubitSetting::get($criteria))) { $setting = $query[0]; $this->form->setDefault('enabled', unserialize($setting->__get('value', array('sourceCulture' => true)))); } $configuration = ProjectConfiguration::getActive(); $pluginPaths = $configuration->getAllPluginPaths(); foreach (sfPluginAdminPluginConfiguration::$pluginNames as $name) { unset($pluginPaths[$name]); } $this->plugins = array(); foreach ($pluginPaths as $name => $path) { $className = $name . 'Configuration'; if (sfConfig::get('sf_plugins_dir') == substr($path, 0, strlen(sfConfig::get('sf_plugins_dir'))) && is_readable($classPath = $path . '/config/' . $className . '.class.php')) { $this->installPluginAssets($name, $path); require_once $classPath; $class = new $className($configuration); // Build a list of themes if (isset($class::$summary) && 1 === preg_match('/theme/i', $class::$summary)) { $this->plugins[$name] = $class; } } } if ($request->isMethod('post')) { $this->form->setValidators(array('enabled' => new sfValidatorChoice(array('choices' => array_keys($this->plugins), 'empty_value' => array(), 'multiple' => true)))); $this->form->bind($request->getPostParameters()); if ($this->form->isValid()) { if (1 != count($query)) { $setting = new QubitSetting(); $setting->name = 'plugins'; } $settings = unserialize($setting->__get('value', array('sourceCulture' => true))); foreach (array_keys($this->plugins) as $item) { if (in_array($item, (array) $this->form->getValue('enabled'))) { $settings[] = $item; } else { if (false !== ($key = array_search($item, $settings))) { unset($settings[$key]); } } } $setting->__set('value', serialize(array_unique($settings))); $setting->save(); // Clear cache $cacheClear = new sfCacheClearTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter()); $cacheClear->run(); $this->redirect(array('module' => 'sfPluginAdminPlugin', 'action' => 'themes')); } } }
/** * Displays the list of existing job queues. * * @param array $arguments (optional) * @param array $options (optional) */ protected function execute($arguments = array(), $options = array()) { $project = ProjectConfiguration::getActive(); $root = $project->getRootDir(); // Setting basic vars.. $model = $arguments['route_or_model']; $name = strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\\d])([A-Z])/'), '\\1_\\2', $model)); $module = $options['module'] ? $options['module'] : $name; $this->path = $root . "/apps/" . $arguments["application"] . "/modules/" . $module; // Theme is always AppFlower.. $options["theme"] = "appFlower"; if (!is_dir($this->path)) { // Reading Schema (from all plugins and the app) if (!file_exists($root . "/config/schema.yml")) { throw new sfCommandException("Couldn't read schema.yml!"); } $this->schema = SchemaUtil::readSchema(true); // Check if routing is used, and determine the model name. $route = $this->getRouteFromName($model); if (false !== $route) { $options = $route->getOptions(); $model = $options["model"]; } // Generate CRUD.. if (!$options["no-forms"]) { $classes = array("sfPropelBuildFormsTask" => "Generating Forms & Filters..", "sfPropelBuildFiltersTask" => ""); foreach ($classes as $class => $message) { $this->runOtherTask(array($class, $message)); } } $this->logBlock("Generating CRUD for " . $arguments["application"] . "/" . $module, "QUESTION"); // is it a model class name if (!class_exists($model)) { throw new sfCommandException(sprintf('The route "%s" does not exist and there is no "%s" class.', $model, $model)); } $r = new ReflectionClass($model); if (!$r->isSubclassOf('BaseObject')) { throw new sfCommandException(sprintf('"%s" is not a Propel class.', $model)); } $arguments["model"] = $model; $arguments["module"] = $module; $this->generate($arguments, $options); $this->logBlock("Generating Widget XML data..", "QUESTION"); // Get schema data.. $data = SchemaUtil::getSchemaDataForModel($model, $this->schema); // Generate widget XMLs.. $this->generateWidgets($data, $model, $module); $this->logBlock("Clearing cache..", "QUESTION"); $this->runOtherTask(array("sfCacheClearTask", null)); $this->logBlock("All done!", "QUESTION"); $this->logSection("Module has been successfuly initialized!", null, null, "INFO"); $this->logSection("Please fill apps/" . $arguments["application"] . "/modules/" . $module . "/config/generator.yml to fine-tune..", null, null, "INFO"); } else { throw new sfCommandException("Module \"" . $module . "\" alerady exists! Please fill generator.yml!"); } }
public function configure() { // SET DEFAULT FORM-FORMATTER /* sfWidgetFormSchema::setDefaultFormFormatterName('bootstrap'); */ sfWidgetFormSchema::setDefaultFormFormatterName('foundation'); ProjectConfiguration::getActive()->loadHelpers( array('I18N') ); }
function sw_combine_debug() { if (ProjectConfiguration::getActive()->isDebug()) { $response = sfContext::getInstance()->getResponse(); echo "<!-- DEBUG MODE - \nCombined information : \n"; foreach ($response->getCombinedAssets() as $information) { echo $information . "\n"; } echo "\n-->\n"; } }
/** * Clears thumb cache if delete_with_cc is set in app.yml * * @param sfEvent $event */ public static function listenToTaskCacheClearEvent(sfEvent $event) { if (!self::getProperty('zsThumb', 'delete_with_cc')) { return; } /* @var $task sfTask */ $task = $event->getSubject(); //$task->runTask('thumb:clear'); $thumb_task = new zsThumbClearTask(ProjectConfiguration::getActive()->getEventDispatcher(), new sfFormatter()); $thumb_task->run(); $task->logSection('zsThumb', 'clearing...'); }
/** * Displays the list of existing job queues. * * @param array $arguments (optional) * @param array $options (optional) */ public function execute($arguments = array(), $options = array()) { if ($arguments["src"] === "none") { $arguments["src"] = null; } if ($arguments["reporting"] != "full" && $arguments["reporting"] != "incremental" && $arguments["reporting"] != "cache" && $arguments["reporting"] != "file") { throw new Exception("Invalid value for argument: reporting. The value 'incremental', 'cache', 'file' or 'full' are expected, but '" . $arguments["reporting"] . "' is given!"); } else { if ($arguments["rebuild"] != "yes" && $arguments["rebuild"] != "no") { throw new Exception("Invalid value for argument: rebuild. The value 'yes' or 'no' are expected, but '" . $arguments["rebuild"] . "' is given!"); } else { if ($arguments["src"] != null && (!file_exists($arguments["src"]) || !is_readable($arguments["src"]))) { throw new Exception("Invalid value for argument: src. The file '" . $arguments["src"] . "' doesn't exist or is not readable!"); } } } $project = ProjectConfiguration::getActive(); $this->basedir = $project->getRootDir(); // Add plugin dirs.. $this->dirs = XmlParser::getPluginDirs($this->basedir . "/plugins"); // DB $this->dbmanager = new sfDatabaseManager($this->configuration); // XML Validator $this->validator = new XmlValidator(null, false, true, $arguments["reporting"] == "cache"); // Truncating cache if ($arguments["rebuild"] == "yes") { afValidatorCachePeer::clearCache(); } if ($arguments["log"] !== null) { $this->log = $arguments["log"]; } $this->args = $arguments; $this->logSection("\nXML Config validation is starting.. (this may take a while)\n" . "Validation type: " . $arguments["reporting"] . " \n" . "Will flush cache: " . $arguments["rebuild"] . " ", null, null, "ERROR"); if ($arguments["reporting"] != "file" && $arguments["src"] == null) { foreach ($this->dirs as $dir) { $scan = substr($dir, 0, 1) == "/" ? $dir : $this->basedir . "/apps/" . $arguments['application'] . "/" . $dir; $this->readConfigs($scan); } } else { $this->validator->readXmlDocument($arguments["src"], true); $result = $this->validator->validateXmlDocument(true); $this->logSection($result[1] === null ? "valid: " : "error: ", $arguments["src"], null, $result[0]); if ($result[1]) { echo Util::arrayToString(array("file" => $tmp, "message" => $result[1]->getMessage())); return true; } } if ($arguments["reporting"] == "full") { $this->printTotal(); } return 0; }
/** * Displays the list of existing job queues. * * @param array $arguments (optional) * @param array $options (optional) */ public function execute($arguments = array(), $options = array()) { $project = ProjectConfiguration::getActive(); $this->root = $project->getRootDir(); $this->arguments = $arguments; $this->dirs = array($this->root . "/web"); FileUtils::getPluginDirs($this->dirs, $this->root, "/web"); $this->logSection("\nXML Generating file list.. (this may take a while)\n" . "File type: " . $arguments["ext"] . " \n", null, null, "ERROR"); foreach ($this->dirs as $dir) { FileUtils::scanDirs($dir, "js", $this->files, true); } $this->printResult(); $this->finalize(); }
/** * Constructor. * * @param string $name Name of the database. */ public function __construct($name) { $this->name = $name; $finder = sfFinder::type('file')->name('*.php'); foreach ($finder->in(array_merge(ProjectConfiguration::getActive()->getPluginSubPaths('/lib/model/map'), array(sfConfig::get('sf_lib_dir') . '/model/map'))) as $path) { require_once $path; } foreach (get_declared_classes() as $className) { $class = new ReflectionClass($className); if ($class->isSubclassOf('TableMap')) { $this->addTableObject(new $className()); } } }
public static function suite() { global $configuration, $plugin_configuration; $suite = new PHPUnit_Framework_TestSuite('sfImageTransformExtraPlugin'); // loading plugin configurations $configuration = ProjectConfiguration::getActive(); $pluginConfig = $configuration->getPluginConfiguration('sfImageTransformExtraPlugin'); // instantiate a fake symfony unit test task to retrieve all connected tests for this plugin $task = new sfTestUnitTask($configuration->getEventDispatcher(), new sfFormatter()); $event = new sfEvent($task, 'task.test.filter_test_files', array('arguments' => array('name' => array()), 'options' => array())); $files = $pluginConfig->filterTestFiles($event, array()); $suite->addTestFiles($files); return $suite; }
/** * Displays the list of existing job queues. * * @param array $arguments (optional) * @param array $options (optional) */ public function execute($arguments = array(), $options = array()) { if ($this->configuration instanceof sfApplicationConfiguration) { sfContext::createInstance($this->configuration); } if (sfContext::hasInstance()) { $context = sfContext::getInstance(); } if (!strstr($arguments["sendto"], "@") && substr($arguments["sendto"], 0, 1) != "/") { throw new Exception("Invalid value for argument: sendto. Either an absolute path or email address is expected, but '" . $arguments["sendto"] . "' is given!"); } $mail = false; if (strstr($arguments["sendto"], "@")) { $msg = "Report will be mailed to " . $arguments["sendto"]; $mail = true; } else { $msg = "Report will be saved to " . $arguments["sendto"]; $this->file = $arguments["sendto"]; } $project = ProjectConfiguration::getActive(); $this->basedir = $project->getRootDir(); $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], 'prod', true); $this->dbmanager = new sfDatabaseManager($configuration); $this->args = $arguments; $this->logSection("\nScan has been started.. (this may take a while)\n" . $msg . " \n", null, null, "ERROR"); $this->result .= "Module;Widget;Credentials;Tested by;Date;In Build;Approved / Disapproved\n"; foreach ($this->dirs as $dir) { $this->readConfigs($this->basedir . "/apps/" . $arguments['application'] . "/" . $dir); } if (!$this->saveFile($mail)) { $this->logSection("Unable to save results to file!", null, null, "ERROR"); exit; } if ($mail) { $msg_to = $arguments["sendto"]; $msg_from = '*****@*****.**'; $subject = $arguments["application"] . " Security Settings"; $content = "Hello!\nThese are the widgets found in " . $this->basedir . "/apps/" . $arguments["application"] . ".\nPlease see attached CSV file.\n\nRegards\nBot"; $attachment = $this->basedir . "/data/security_tmp.csv"; $attachment_name = "widget_data.csv"; $message = sfContext::getInstance()->getMailer()->compose($msg_from, $msg_to, $subject, $content)->setContentType('text/html'); $message->attach(Swift_Attachment::fromPath($attachment)->setFilename($attachment_name)); sfContext::getInstance()->getMailer()->send($message); $this->logSection("Sending message..", "(please wait..)"); $this->printTotal(true); } else { $this->printTotal(false); } }
public function preExecute() { // $module = 'sf_plop_guard_user_address'; // if (!in_array($module, array_keys(sfPlop::getSafePluginModules())) // && !$this->getUser()->hasCredential($module) // ) // $this->forward404(); if (!$this->getUser()->isAuthenticated()) { $this->forward(sfConfig::get('sf_login_module'), sfConfig::get('sf_login_action')); } // if (!$this->getUser()->hasCredential($module)) // $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); parent::preExecute(); ProjectConfiguration::getActive()->LoadHelpers(array('I18N')); $this->getResponse()->setTitle(sfPlop::setMetaTitle(__('User addresses', '', 'plopAdmin'))); }
/** * Обрабатывает событие из dispatcher */ public function listenToLogEvent(sfEvent $event) { $subject = $event->getSubject(); $parameters = $event->getParameters(); try { $record = new myDoctrineLoggerEvent(); } catch (Exception $e) { new sfDatabaseManager(ProjectConfiguration::getActive()); $record = new myDoctrineLoggerEvent(); } // Статус: fail, info, notice, warning if (isset($parameters['state'])) { $definition = Doctrine_Core::getTable('myDoctrineLoggerEvent')->getColumnDefinition('state'); $states = $definition['values']; if (in_array($parameters['state'], $states)) { $record->setState($parameters['state']); } } // Идентификатор связанного объекта, если есть if (isset($parameters['object'])) { $record->setModelId((int) $parameters['object']); } // Идентификатор пользователя - инициатора события, если есть if (isset($parameters['user'])) { if (is_object($parameters['user']) && $parameters['user'] instanceof Doctrine_Record) { $parameters['user'] = $parameters['user']->getId(); } $record->setUserId((int) $parameters['user']); } // Компонент приложения $record->setComponent(isset($parameters['component']) ? (string) $parameters['component'] : 'UNKNOWN'); // Название события if (!isset($parameters['name'])) { throw new sfException('Необходимо назвать событие: заполнить параметр ["name"]'); } $record->setLabel((string) $parameters['name']); // расшифровка результата if (!isset($parameters['description'])) { throw new sfException('Необходимо назвать событие: заполнить параметр ["description"]'); } $record->setResult((string) $parameters['description']); // Данные события if (isset($parameters['env'])) { $record->setContext((string) $parameters['env']); } $record->save(); }
public function preExecute() { $module = 'sf_extranet_event'; if (!in_array($module, array_keys(sfPlop::getSafePluginModules()))) { $this->forward404(); } if (!$this->getUser()->isAuthenticated()) { $this->forward(sfConfig::get('sf_login_module'), sfConfig::get('sf_login_action')); } if (!$this->getUser()->hasCredential($module)) { $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); } parent::preExecute(); $user = $this->getUser(); $user->setCulture($user->getProfile()->getCulture()); ProjectConfiguration::getActive()->LoadHelpers(array('I18N')); $this->getResponse()->setTitle(sfPlop::setMetaTitle(__('Extranet events', '', 'plopAdmin'))); }
/** * Executes this configuration handler. * * @param array $configFiles An array of absolute filesystem path to a configuration file * * @return string Data to be written to a cache file * * @throws sfConfigurationException If a requested configuration file does not exist or is not readable * @throws sfParseException If a requested configuration file is improperly formatted */ public function execute($configFiles) { $config = sfFactoryConfigHandler::getConfiguration(ProjectConfiguration::getActive()->getConfigPaths('config/factories.yml')); $options = $config['module_manager']['param']; $managerClass = $config['module_manager']['class']; $this->parse($configFiles); $this->validate(); $this->processHierarchy(); $this->sortModuleTypes(); $data = array(); $data[] = sprintf('$manager = new %s();', $managerClass); $data[] = sprintf('$modules = $projectModules = $modelModules = $types = array();'); foreach ($this->config as $typeName => $typeConfig) { $data[] = sprintf('$types[\'%s\'] = new %s();', $typeName, $options['type_class']); $data[] = sprintf('$typeSpaces = array();'); foreach ($typeConfig as $spaceName => $modulesConfig) { $data[] = sprintf('$typeSpaces[\'%s\'] = new %s();', $spaceName, $options['space_class']); $data[] = sprintf('$spaceModules = array();'); foreach ($modulesConfig as $moduleKey => $moduleConfig) { $moduleClass = $options[$moduleConfig['is_project'] ? 'module_node_class' : 'module_base_class']; if ($moduleConfig['is_project']) { $moduleReceivers = sprintf('$modules[\'%s\'] = $projectModules[\'%s\'] = $spaceModules[\'%s\']', $moduleKey, $moduleKey, $moduleKey); } else { $moduleReceivers = sprintf('$modules[\'%s\'] = $spaceModules[\'%s\']', $moduleKey, $moduleKey); } $data[] = sprintf('%s = new %s(\'%s\', $typeSpaces[\'%s\'], %s);', $moduleReceivers, $moduleClass, $moduleKey, $spaceName, $this->getExportedModuleOptions($moduleKey, $moduleConfig)); if ($moduleConfig['model']) { $data[] = sprintf('$modelModules[\'%s\'] = \'%s\';', $moduleConfig['model'], $moduleKey); } } $data[] = sprintf('$typeSpaces[\'%s\']->initialize(\'%s\', $types[\'%s\'], $spaceModules);', $spaceName, $spaceName, $typeName); $data[] = 'unset($spaceModules);'; } $data[] = sprintf('$types[\'%s\']->initialize(\'%s\', $typeSpaces);', $typeName, $typeName); $data[] = 'unset($typeSpaces);'; } $data[] = sprintf('$manager->load($types, $modules, $projectModules, $modelModules);'); $data[] = 'unset($types, $modules, $projectModules, $modelModules);'; $data[] = 'return $manager;'; unset($this->config, $this->modules, $this->projectModules); return sprintf("<?php\n" . "// auto-generated by dmModuleManagerConfigHandler\n" . "// date: %s\n%s", date('Y/m/d H:i:s'), implode("\n", $data)); }
/** * Displays the list of existing job queues. * * @param array $arguments (optional) * @param array $options (optional) */ public function execute($arguments = array(), $options = array()) { $project = ProjectConfiguration::getActive(); // Paths.. $this->basedir = $project->getRootDir(); $this->modules_dir = $project->getRootDir() . "/apps/" . $arguments['application'] . "/modules"; $this->fixtures["category"]["data"] = $this->fixtures["selector"]["data"] = ""; $this->yml_path = $this->basedir . "/data/fixtures/widget_selector.yml"; $this->args = $arguments; // Init DB $configuration = ProjectConfiguration::getApplicationConfiguration($this->args["application"], 'prod', true); @sfContext::createInstance($configuration); $this->context = sfContext::getInstance(); $this->dbmanager = new sfDatabaseManager($this->configuration); if ($arguments["clear"] == "yes") { $this->logSection("\nClearing database..\n", null, 60, "ERROR"); afWidgetSelectorPeer::clear(); afWidgetCategoryPeer::clear(); $this->logSection("Done..", null); $this->logSection("\nRemoving fixture file..\n", null, 60, "ERROR"); $this->logSection("File: ", $this->yml_path); if (file_exists($this->yml_path)) { if (!@unlink($this->yml_path)) { throw new Exception("Unable to delete file: " . $this->yml_path); } } } // Parse page configs for widget params. $this->logSection("\nScanning page configs..\n", null, 60, "ERROR"); $this->parsePages(); $this->logSection("Done..", null); // Doing job.. $this->logSection("\nScanning modules..\n", null, 60, "ERROR"); // Create / Update DB and file data.. $this->doUpdate($this->modules_dir); // Save YML fixture file.. $this->saveFixture(); // Clearing unused widget data.. $this->doDBCleanup(); }
public static function getDownloadablePluginPaths() { $cachePath = sfConfig::get('sf_cache_dir') . '/sympal/plugins.cache'; if (!file_exists($cachePath)) { $installedPlugins = ProjectConfiguration::getActive()->getPlugins(); $available = array(); $paths = sfSympalConfig::get('plugin_sources'); foreach ($paths as $path) { if (is_dir($path)) { $find = sfFinder::type('dir')->maxdepth(1)->name('sfSympal*Plugin')->in($path); foreach ($find as $p) { $info = pathinfo($p); if (!isset($available[$info['basename']])) { $available[$info['basename']] = $p; } } } else { $html = sfSympalToolkit::fileGetContents($path); preg_match_all("/sfSympal(.*)Plugin/", strip_tags($html), $matches); foreach ($matches[0] as $plugin) { if (!isset($available[$plugin])) { $available[$plugin] = $path; } } } } if (isset($available['sfSympalPlugin'])) { unset($available['sfSympalPlugin']); } if (!is_dir($dir = dirname($cachePath))) { mkdir($dir, 0777, true); } file_put_contents($cachePath, serialize($available)); } else { $content = file_get_contents($cachePath); $available = unserialize($content); } return $available; }
/** * @param mixed $object object or string, or null * @param string $message * @param int $priority sfLogger::* see constants */ public static function notifyApplicationLog($object, $message, $priority = null) { ProjectConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($object, 'application.log', array($message))); }
<?php /* * This file is part of the symfony package. * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ $_test_dir = realpath(dirname(__FILE__) . '/..'); // configuration require_once dirname(__FILE__) . '/../../config/ProjectConfiguration.class.php'; $configuration = ProjectConfiguration::hasActive() ? ProjectConfiguration::getActive() : new ProjectConfiguration(realpath($_test_dir . '/..')); // autoloader $autoload = sfSimpleAutoload::getInstance(sfConfig::get('sf_cache_dir') . '/project_autoload.cache'); $autoload->loadConfiguration(sfFinder::type('file')->name('autoload.yml')->in(array(sfConfig::get('sf_symfony_lib_dir') . '/config/config', sfConfig::get('sf_config_dir')))); $autoload->addDirectory(sfConfig::get('sf_apps_dir')); $autoload->addDirectory($_test_dir); $autoload->register(); // lime include $configuration->getSymfonyLibDir() . '/vendor/lime/lime.php'; // hamcrest set_include_path(get_include_path() . PATH_SEPARATOR . sfConfig::get("sf_lib_dir") . '/vendor/hamcrest/hamcrest'); require_once 'Hamcrest.php';
* This file is part of Qubit Toolkit. * * Qubit Toolkit is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Qubit Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>. */ ProjectConfiguration::getActive()->loadHelpers('I18N'); /** * Global form definition for settings module - with validation. * * @package qubit * @subpackage settings * @version svn: $Id$ * @author Peter Van Garderen <*****@*****.**> */ class SettingsOaiRepositoryForm extends sfForm { protected static $resumptionTokenMinLimit = 10; protected static $resumptionTokenMaxLimit = 1000; public function configure() { // Build widgets
/** * @return sfEventDispatcher */ protected function getDispatcher(sfWebRequest $request) { return ProjectConfiguration::getActive()->getEventDispatcher(array('request' => $request)); }
function render_value($value) { ProjectConfiguration::getActive()->loadHelpers('Text'); $value = auto_link_text($value); // Simple lists $value = preg_replace('/(?:^\\*.*\\r?\\n)*(?:^\\*.*)/m', "<ul>\n\$0\n</ul>", $value); $value = preg_replace('/(?:^-.*\\r?\\n)*(?:^-.*)/m', "<ul>\n\$0\n</ul>", $value); $value = preg_replace('/^(?:\\*|-)\\s*(.*)(?:\\r?\\n)?/m', '<li>$1</li>', $value); $value = preg_replace('/(?:\\r?\\n){2,}/', "</p><p>", $value, -1, $count); if (0 < $count) { $value = "<p>{$value}</p>"; } $value = preg_replace('/\\r?\\n/', '<br/>', $value); return $value; }
<?php require_once 'config.php'; // this check prevents access to debug front controllers that are deployed by accident to production servers. // feel free to remove this, extend it or make something more sophisticated. if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) { die('You are not allowed to access this file. Check ' . basename(__FILE__) . ' for more information.'); } require_once $options['sf_root_dir'] . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'ProjectConfiguration.class.php'; $configuration = ProjectConfiguration::getApplicationConfiguration('siwapp', 'dev', true); ProjectConfiguration::getActive()->setWebDir($options['sf_web_dir']); sfContext::createInstance($configuration)->dispatch();
public function configure() { ProjectConfiguration::getActive()->loadHelpers(array('I18N', 'OrangeDate', 'Orange', 'Url')); sfWidgetFormSchema::setDefaultFormFormatterName('Default'); }