本文整理汇总了PHP中sfProjectConfiguration::getActive方法的典型用法代码示例。如果您正苦于以下问题:PHP sfProjectConfiguration::getActive方法的具体用法?PHP sfProjectConfiguration::getActive怎么用?PHP sfProjectConfiguration::getActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfProjectConfiguration
的用法示例。
在下文中一共展示了sfProjectConfiguration::getActive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateMetaDescription
protected function generateMetaDescription()
{
sfProjectConfiguration::getActive()->loadHelpers('StringFunc');
$result = '';
switch ($this->getCurrentPageType()) {
case self::ARTICLE_PAGE:
//pealkiri. Sisu (250 chars)
if ($this->getRoute()->getObject()->getMetadescription()) {
return $this->getRoute()->getObject()->getMetadescription();
}
$content = truncate(strip_tags($this->getRoute()->getObject()->getTitle() . '. ' . $this->getRoute()->getObject()->getContent()), 250, '');
break;
case self::CATEGORY_PAGE:
// category name, products
if ($this->getRoute()->getCategoryObject()->getMetaDescription()) {
return $this->getRoute()->getCategoryObject()->getMetaDescription();
}
$content = implode(',', $this->getProductCategoryPageWords($this->getRoute()->getCategoryObject()));
break;
case self::PRODUCT_PAGE:
//toote nimi (kategooriad) - toode kirjelduse esimesed tähemärgid
$content = $this->getRoute()->getProductObject()->getName() . ' (' . implode(', ', $this->getProductCategoryPageWords($this->getRoute()->getCategoryObject())) . ') ' . $this->getRoute()->getProductObject()->getDescription();
break;
}
$result = truncate(strip_tags($content), 250, '');
return $result;
}
示例2: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$this->class = $request->getParameter('class');
if (empty($this->class)) {
$this->class = $request->getGetParameter('class');
}
$this->method = $request->getParameter('method');
if (empty($this->method)) {
$this->method = $request->getGetParameter('method');
}
if (!empty($this->method)) {
$this->class = array($this->class, $this->method);
}
$this->viewer = new sfCodeViewer($this->class);
if ($request->isXmlHttpRequest()) {
sfProjectConfiguration::getActive()->loadHelpers('Url');
$this->renderText($this->viewer->render(url_for('sfCodeView')));
return sfView::NONE;
} else {
// maintain history
$this->history = $this->getUser()->getAttribute('history', array());
if (false !== ($index = array_search($this->class, $this->history))) {
unset($this->history[$index]);
}
array_unshift($this->history, $this->class);
array_splice($this->history, 10);
$this->getUser()->setAttribute('history', $this->history);
}
}
示例3: getDefaultCulture
public static function getDefaultCulture()
{
if (!self::$initialized && class_exists('sfProjectConfiguration', false)) {
self::initialize(sfProjectConfiguration::getActive()->getEventDispatcher());
}
return self::$defaultCulture;
}
示例4: executeNovaPagina
public function executeNovaPagina(sfWebRequest $request)
{
if ($request->isXmlHttpRequest() || true) {
//apenas por ajax
sfConfig::set('sf_web_debug', false);
sfProjectConfiguration::getActive()->loadHelpers(array('I18N', 'Date'));
$cmspage = new Cmspage();
$content = new Content();
$content->setId(null);
$cmspage->setContent($content);
$cmspage->setId(null);
$cmsGroupcontent = $this->getUser()->getAttribute('contentGroup');
$this->forward404Unless($cmsGroupcontent);
$cmspage->setCmsgroupcontent($cmsGroupcontent);
$this->formContent = new PageContentForm($cmspage);
if ($request->isMethod('post')) {
//return $this->renderPartial('cms/debug',array('values'=>$request->getParameter('pagina')));
$this->formContent->bind($request->getParameter('pagina'));
if ($this->formContent->isValid()) {
$this->logMessage('O formContent foi válido. cms/actions: ' . __FILE__ . __LINE__);
try {
$this->formContent->save();
return $this->renderPartial("cms/viewPage", array('page' => $this->formContent->getCmspageobj(), 'isNew' => true, 'values' => $this->formContent->getValues()));
} catch (Exception $e) {
//TODO: We should to handle the error and render it.
throw $e;
}
//return $this->renderPartial("cms/viewPage",array('page'));
}
}
//parent::executeNew($request);
return $this->renderPartial('cms/content_form', array('formContent' => $this->formContent));
}
}
示例5: setup
public function setup()
{
parent::setup();
sfProjectConfiguration::getActive()->loadHelpers(array('I18N'));
$this->required = __('Required', array(), 'vjComment');
$this->invalid_mail = __('Invalid Mail', array(), 'vjComment');
$this->invalid_url = __('Invalid Url', array(), 'vjComment');
$this->required_msg = __('Required message', array(), 'vjComment');
$this->widgetSchema['record_model'] = new sfWidgetFormInputHidden();
$this->widgetSchema['record_id'] = new sfWidgetFormInputHidden();
$this->widgetSchema['reply'] = new sfWidgetFormInputHidden();
$this->widgetSchema['reply_author'] = new sfWidgetFormInputHidden();
$this->widgetSchema['user_name'] = new sfWidgetFormInputHidden();
$this->validatorSchema['reply'] = new sfValidatorPass();
$this->validatorSchema['reply_author'] = new sfValidatorPass();
$this->validatorSchema['user_name'] = new sfValidatorPass();
$this->widgetSchema->setLabel('author_name', __('Name', array(), 'vjComment'));
$this->widgetSchema->setLabel('author_email', 'Email');
$this->widgetSchema->setLabel('author_website', __('Website', array(), 'vjComment'));
$this->widgetSchema->setLabel('body', 'Message');
$this->widgetSchema->setHelp('author_website', __('Must start with http:// or https://', array(), 'vjComment'));
$this->validatorSchema['author_email'] = new sfValidatorEmail();
$this->validatorSchema['author_website'] = new sfValidatorUrl();
$this->validatorSchema['author_name']->setMessage('required', $this->required);
$this->validatorSchema['author_email']->setMessage('required', $this->required)->setMessage('invalid', $this->invalid_mail);
$this->validatorSchema['author_website']->setOption('required', false)->setMessage('invalid', $this->invalid_url);
$this->validatorSchema['body']->setOption('required', true)->setMessage('required', $this->required_msg);
}
示例6: reloadClasses
public function reloadClasses($force = false)
{
// only (re)load the autoloading cache once per request
if (self::$freshCache) {
return;
}
$configuration = sfProjectConfiguration::getActive();
if (!$configuration || !$configuration instanceof sfApplicationConfiguration) {
return;
}
self::$freshCache = true;
if (file_exists($configuration->getConfigCache()->getCacheName('config/autoload.yml'))) {
self::$freshCache = false;
if ($force) {
unlink($configuration->getConfigCache()->getCacheName('config/autoload.yml'));
}
}
$file = $configuration->getConfigCache()->checkConfig('config/autoload.yml');
$this->classes = (include $file);
//If the user has specified provided one or more class paths
foreach ($this->overriden as $class => $path) {
$this->classes[$class] = $path;
}
//Remove non Peer classes from the array.
foreach ($this->classes as $className => $path) {
if (substr($className, -4, 4) != 'Peer' || substr($className, -4, 4) == 'Peer' && substr($className, 0, 4) == 'Base') {
unset($this->classes[$className]);
}
}
}
示例7: execute
protected function execute($arguments = array(), $options = array()) {
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
$context = sfContext::createInstance($this->configuration);
sfProjectConfiguration::getActive()->loadHelpers('Partial', 'I18N', 'Url');
$serverUrl = $options['setenvironment'] == '' ? $serverUrl = $options['host'] : $serverUrl = $options['host'] . '/' . $options['setenvironment'];
$workflows = WorkflowVersionTable::instance()->getWorkflowsToStart(time())->toArray();
foreach($workflows as $workflow) {
$sender = WorkflowTemplateTable::instance()->getWorkflowTemplateById($workflow['workflowtemplate_id'])->toArray();
$userSettings = new UserMailSettings($sender[0]['sender_id']);
$sendMail = new SendStartWorkflowEmail($userSettings, $context, $workflow, $sender, $serverUrl);
$workflowTemplate = WorkflowTemplateTable::instance()->getWorkflowTemplateByVersionId($workflow['id']);
WorkflowVersionTable::instance()->startWorkflowInFuture($workflow['id']);
$sendToAllSlotsAtOnce = $workflowTemplate[0]->getMailinglistVersion()->toArray();
if($sendToAllSlotsAtOnce[0]['sendtoallslotsatonce'] == 1) {
$calc = new CreateWorkflow($workflow['id']);
$calc->setServerUrl($serverUrl);
$calc->setContext($context);
$calc->addAllSlots();
}
else {
$calc = new CreateWorkflow($workflow['id']);
$calc->setServerUrl($serverUrl);
$calc->setContext($context);
$calc->addSingleSlot();
}
}
}
示例8: reloadClasses
public function reloadClasses($force = false)
{
if (self::$freshCache && !$force)
{
return false;
}
$configuration = sfProjectConfiguration::getActive();
if (!$configuration || !$configuration instanceof sfApplicationConfiguration)
{
return false;
}
self::$freshCache = true;
if (file_exists($configuration->getConfigCache()->getCacheName('config/autoload.yml')))
{
self::$freshCache = false;
if ($force)
{
unlink($configuration->getConfigCache()->getCacheName('config/autoload.yml'));
}
}
$file = $configuration->getConfigCache()->checkConfig('config/autoload.yml');
$this->classes = include($file);
foreach ($this->overriden as $class => $path)
{
$this->classes[$class] = $path;
}
return true;
}
示例9: get
public static function get()
{
sfProjectConfiguration::getActive()->loadHelpers(array("Url"));
sfProjectConfiguration::getActive()->loadHelpers(array("Tag"));
//TODO: fix this
return "<div id='skulebar'>\n\t\t<a id='skule' href='/'>Skule Courses</a>\n\t\t<form method='get' action='" . url_for("search/fuzzySearch") . "' name='frmSearchBar'>\n\t\t<div style='margin: 0pt; padding: 0pt; display: inline;'>\n\t\t</div>\n\t\t<input type='text' title='Quick search in Skule Courses' size='30' name='query' id='search_search' autocomplete='off'/>\n\t\t</form>\n\t\t<div id='user'>\n\t\t<a href='/login'>Login</a>\n\t\t</div>\n\t\t</div>";
}
示例10: __construct
public function __construct($containerObject, $attributes = array())
{
$this->afExtjs = afExtjs::getInstance();
if (isset($attributes['label'])) {
$this->attributes['text'] = $attributes['label'];
unset($attributes['label']);
}
if (isset($attributes['url'])) {
$param_name = isset($attributes['param']) ? $attributes['param'] : "param";
$url = $attributes['url'] . "&" . $param_name . "=";
$param = $containerObject->privateName . '.stack["text"]';
$cellDiv = $containerObject->privateName . '.stack["cellDiv"]';
if (isset($attributes['ajax'])) {
sfProjectConfiguration::getActive()->loadHelpers(array('afExtjsContextMenu'));
$source = ajax_source($url . '"+' . $param);
} else {
$source = 'window.location.href="' . $url . '"+' . $param;
}
$this->attributes['handler'] = $this->afExtjs->asMethod(array('parameters' => '', 'source' => $source));
unset($attributes['url']);
unset($attributes['ajax']);
unset($attributes['param']);
}
if (isset($attributes['source'])) {
$this->attributes['handler'] = $this->afExtjs->asMethod(array('parameters' => '', 'source' => $attributes["source"]));
}
parent::__construct($containerObject, $attributes);
}
示例11: configure
public function configure()
{
sfProjectConfiguration::getActive()->loadHelpers(array('Asset', 'Thumb'));
$this->widgetSchema['asso_id'] = new sfWidgetFormInputHidden();
$this->widgetSchema['start_date'] = new sfWidgetDatePicker();
$this->validatorSchema['start_date'] = new sfValidatorDatePicker(array());
$this->widgetSchema['end_date'] = new sfWidgetDatePicker();
$this->validatorSchema['end_date'] = new sfValidatorDatePicker(array());
$this->widgetSchema['affiche'] = new sfWidgetFormInputFileEditable(array('file_src' => doThumb($this->getObject()->getAffiche(), 'events', array('width' => 150, 'height' => 150), 'scale'), 'is_image' => true, 'edit_mode' => !$this->isNew() && $this->getObject()->getAffiche(), 'with_delete' => true, 'delete_label' => "Supprimer cette illustration"));
$this->validatorSchema['affiche'] = new sfValidatorFileImage(array('required' => false, 'path' => sfConfig::get('sf_upload_dir') . '/events/source', 'mime_types' => 'web_images', 'max_width' => 1000, 'max_height' => 1000));
$this->widgetSchema['guest_asso_list']->setOption('method', 'getName');
$this->widgetSchema->setLabel('guest_asso_list', 'Associations Partenaires');
$this->widgetSchema['guest_asso_list']->setAttributes(array('style' => 'width:100%;', 'class' => 'select2'));
$this->validatorSchema['affiche_delete'] = new sfValidatorBoolean();
$this->widgetSchema->setLabel('name', 'Nom');
$this->widgetSchema->setLabel('type_id', 'Type');
$this->widgetSchema->setLabel('start_date', 'Début');
$this->widgetSchema->setLabel('end_date', 'Fin');
$this->widgetSchema->setLabel('summary', 'Résumé en une ligne');
$this->widgetSchema->setLabel('description', 'Description');
$this->widgetSchema->setLabel('place', 'Lieu');
$this->widgetSchema->setLabel('is_public', 'Ouvert au public ?');
$this->widgetSchema->setLabel('affiche', 'Illustration');
$this->widgetSchema->setLabel('is_weekmail', 'Paraître dans le Weekmail ?');
$this->widgetSchema['is_weekmail']->setAttribute('style', 'width: 15px;');
$this->useFields(array('asso_id', 'name', 'type_id', 'start_date', 'end_date', 'summary', 'description', 'place', 'is_public', 'affiche', 'is_weekmail', 'guest_asso_list'));
}
示例12: __toString
public function __toString()
{
$linkable = $this->getPropertyValue('linkable', true);
if ($linkable instanceof sfOutputEscaperArrayDecorator || is_array($linkable)) {
list($method, $params) = $linkable;
$linkable = call_user_func_array(array($this->dataObject, $method), $params->getRawValue());
}
if ($linkable) {
$placeholderGetters = $this->getPropertyValue('placeholderGetters');
$urlPattern = $this->getPropertyValue('urlPattern');
$url = $urlPattern;
foreach ($placeholderGetters as $placeholder => $getter) {
$placeholderValue = is_array($this->dataObject) ? $this->dataObject[$getter] : $this->dataObject->{$getter}();
$url = preg_replace("/\\{{$placeholder}\\}/", $placeholderValue, $url);
}
if (preg_match('/^index.php/', $url)) {
sfProjectConfiguration::getActive()->loadHelpers('Url');
$url = public_path($url, true);
}
$linkAttributes = array('href' => $url);
if ($this->hasProperty('labelGetter')) {
$label = $this->getValue('labelGetter');
} else {
$label = $this->getPropertyValue('label', 'Undefined');
}
return content_tag('a', $label, $linkAttributes) . $this->getHiddenFieldHTML();
} else {
return $this->toValue() . $this->getHiddenFieldHTML();
}
}
示例13: initialize
/**
* Initializes the current sfGenerator instance.
*
* @param sfGeneratorManager $generatorManager A sfGeneratorManager instance
*/
public function initialize(sfGeneratorManager $generatorManager)
{
parent::initialize($generatorManager);
$configuration = sfProjectConfiguration::getActive();
$this->databaseManager = new sfDatabaseManager($configuration);
$this->setGeneratorClass('sfDoctrineModule');
}
示例14: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$this->user = $this->getUser();
//$user_id = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
$user = $this->getUser()->getRaykuUser();
if ($user) {
$user_id = $user->getId();
}
if (!$user_id) {
$this->forward('/dashboard');
}
$this->setVar('user_id', $user_id);
//Form submitted
if (sfWebRequest::POST == $this->getRequest()->getMethod()) {
$emails = $this->getRequestParameter('emails');
$ref = $this->getRequestParameter('ref');
if (!$emails) {
echo "Invalid emails";
return false;
}
$mail = Mailman::createMailer();
$mail->setContentType('text/html');
$mail->addAddress($emails);
$mail->setSubject('Invitation');
sfProjectConfiguration::getActive()->loadHelpers(array('Asset', 'Url', 'Partial'));
$mail->setBody(get_partial('invitationEmailHtml', array('ref' => $ref, 'user' => $user)));
$mail->send();
//$this->forward('referrals', 'invitesSent');
}
}
示例15: initialize
/**
* Initialize a sfDoctrineDatabase connection with the given parameters.
*
* <code>
* $parameters = array(
* 'name' => 'doctrine',
* 'dsn' => 'sqlite:////path/to/sqlite/db');
*
* $p = new sfDoctrineDatabase($parameters);
* </code>
*
* @param array $parameters Array of parameters used to initialize the database connection
* @return void
*/
public function initialize($parameters = array())
{
parent::initialize($parameters);
$dsn = $this->getParameter('dsn');
$name = $this->getParameter('name');
// Make sure we pass non-PEAR style DSNs as an array
if (!strpos($dsn, '://')) {
$dsn = array($dsn, $this->getParameter('username'), $this->getParameter('password'));
}
// Make the Doctrine connection for $dsn and $name
$this->_doctrineConnection = Doctrine_Manager::connection($dsn, $name);
$attributes = $this->getParameter('attributes', array());
foreach ($attributes as $name => $value) {
$this->_doctrineConnection->setAttribute($name, $value);
}
$encoding = $this->getParameter('encoding', 'UTF8');
$eventListener = new sfDoctrineConnectionListener($this->_doctrineConnection, $encoding);
$this->_doctrineConnection->addListener($eventListener);
// Load Query Logger Listener
if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
$this->_doctrineConnection->addListener(new sfDoctrineLogger());
}
// Invoke the configuration methods for the connection if they exist
$configuration = sfProjectConfiguration::getActive();
$method = sprintf('configureDoctrineConnection%s', ucwords($this->_doctrineConnection->getName()));
if (method_exists($configuration, 'configureDoctrineConnection') && !method_exists($configuration, $method)) {
$configuration->configureDoctrineConnection($this->_doctrineConnection);
}
if (method_exists($configuration, $method)) {
$configuration->{$method}($this->_doctrineConnection);
}
}