本文整理汇总了PHP中sfApplicationConfiguration类的典型用法代码示例。如果您正苦于以下问题:PHP sfApplicationConfiguration类的具体用法?PHP sfApplicationConfiguration怎么用?PHP sfApplicationConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfApplicationConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(sfApplicationConfiguration $applicationConfiguration, $yaml_handler = 'sfYaml')
{
$this->checkYamlHandler($yaml_handler);
$this->environment = $applicationConfiguration->getEnvironment();
$this->application_configuration = $applicationConfiguration;
$this->config_path = $this->getConfigurationPath();
$this->entry = $this->getEntry();
}
示例2: initialize
/**
* Initializes this class.
*
* Available options:
*
* * culture: The culture
* * source: The i18n source (XLIFF by default)
* * debug: Whether to enable debug or not (false by default)
* * database: The database name (default by default)
* * untranslated_prefix: The prefix to use when a message is not translated
* * untranslated_suffix: The suffix to use when a message is not translated
*
* @param sfApplicationConfiguration $configuration A sfApplicationConfiguration instance
* @param sfCache $cache A sfCache instance
* @param array $options An array of options
*/
public function initialize(sfApplicationConfiguration $configuration, sfCache $cache = null, $options = array())
{
$this->configuration = $configuration;
$this->dispatcher = $configuration->getEventDispatcher();
$this->cache = $cache;
if (isset($options['culture'])) {
$this->setCulture($options['culture']);
unset($options['culture']);
}
$this->options = array_merge(array('source' => 'XLIFF', 'debug' => false, 'database' => 'default', 'untranslated_prefix' => '[T]', 'untranslated_suffix' => '[/T]'), $options);
$this->dispatcher->connect('user.change_culture', array($this, 'listenToChangeCultureEvent'));
if ($this->isMessageSourceFileBased($this->options['source'])) {
$this->dispatcher->connect('controller.change_action', array($this, 'listenToChangeActionEvent'));
}
}
示例3: initialize
/**
* Initializes the current sfContext instance.
*
* @param sfApplicationConfiguration $configuration An sfApplicationConfiguration instance
*/
public function initialize(sfApplicationConfiguration $configuration)
{
$this->configuration = $configuration;
$this->dispatcher = $configuration->getEventDispatcher();
try {
$this->loadFactories();
} catch (sfException $e) {
$e->printStackTrace();
} catch (Exception $e) {
sfException::createFromException($e)->printStackTrace();
}
$this->dispatcher->connect('template.filter_parameters', array($this, 'filterTemplateParameters'));
// register our shutdown function
register_shutdown_function(array($this, 'shutdown'));
}
示例4: sendNotification
public static function sendNotification($fromMember, $toMember, $diaryId)
{
$url = '/diary/' . $diaryId;
sfApplicationConfiguration::getActive()->loadHelpers(array('I18N'));
$message = format_number_choice('[1]1 diary has new comments|(1,Inf]%1% diaries have new comments', array('%1%' => '1'), 1);
opNotificationCenter::notify($fromMember, $toMember, $message, array('category' => 'other', 'url' => $url, 'icon_url' => null));
}
示例5: Header
public function Header()
{
$appConf = sfApplicationConfiguration::getActive();
if (method_exists($appConf, 'configGet')) {
$pdfLogo = $appConf->configGet('app_pdf_logo');
} else {
$pdfLogo = sfConfig::get('app_pdf_logo');
}
$logos = array("af" => sfConfig::get("app_appFlower_logo"), "partner" => $pdfLogo);
if (!$logos["af"] || !file_exists($logos["af"]["file"])) {
$logos["af"]["file"] = sfConfig::get("sf_root_dir") . "/plugins/appFlowerPlugin/web/images/logo.png";
}
$ps = $this->orientation == "P" ? 210 : 297;
$this->Image($logos["af"]["file"], 10, 5, 0, 0, '', $logos["af"]["url"]);
$p1 = getimagesize($logos["af"]["file"]);
if ($logos["partner"]) {
if (!file_exists($logos["partner"]["file"])) {
$logos["partner"]["file"] = sfConfig::get("sf_root_dir") . "/web" . $logos["partner"]["file"];
}
if (file_exists($logos["partner"]["file"]) && is_file($logos["partner"]["file"])) {
$p2 = getimagesize($logos["partner"]["file"]);
$this->Image($logos["partner"]["file"], $ps - $this->getMMValue($p2[0]) - 10, 5, 0, 0, '', $logos["partner"]["url"]);
} else {
$p2 = array(0, 0);
}
} else {
$p2 = array(0, 0);
}
$mh = max(array($p1[1], $p2[1]));
$this->setY($mh / 72 * 25.4 + 5);
$this->SetFont('Arial', 'B', 10);
$this->Cell(0, 10, ucwords($this->widget["title"]) . " Widget", "B", 1, "L");
$this->Ln(5);
}
示例6: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$this->checkPluginExists($arguments['plugin']);
$this->pluginDir = sfApplicationConfiguration::getActive()->getPluginConfiguration($arguments['plugin'])->getRootDir();
$this->interactive = !$options['non-interactive'];
$cleanup = array();
if (!file_exists($this->pluginDir . '/package.xml')) {
$cleanup['temp_files'] = array();
foreach (sfFinder::type('dir')->in($this->pluginDir) as $dir) {
if (!sfFinder::type('any')->maxdepth(0)->in($dir)) {
$this->getFilesystem()->touch($file = $dir . '/.sf');
$cleanup['temp_files'][] = $file;
}
}
$cleanup['package_file'] = true;
$this->generatePackageFile($arguments, $options);
}
$cwd = getcwd();
chdir($this->pluginDir);
$this->getPluginManager()->configure();
require_once 'PEAR/Packager.php';
$packager = new PEAR_Packager();
$package = $packager->package($this->pluginDir . '/package.xml', !$options['nocompress']);
chdir($cwd);
if (PEAR::isError($package)) {
if (isset($cleanup['package_file'])) {
$cleanup['package_file'] = '.error';
}
$this->cleanup($cleanup);
throw new sfCommandException($package->getMessage());
}
$this->cleanup($cleanup);
}
示例7: AddComment
private function AddComment(sfWebRequest $request)
{
$text = $request->getParameter('comment_text');
if ($request->isMethod("GET")) {
$text = urldecode($text);
}
if ($this->getRequestParameter('comment_picture_url')) {
$filename = jrFileUploader::UploadRemote($request->getParameter('comment_picture_url'));
if ($text) {
$text .= "<br/>";
}
$text .= "<img src='http://" . $request->getHost() . "/uploads/" . $filename . "' />";
}
if (!trim($text)) {
return;
}
sfApplicationConfiguration::getActive()->loadHelpers(array('Parse', 'Text', 'Tag', 'I18N', 'Url'));
$user = $this->getUser()->getGuardUser();
$comment = new PostComment();
$comment->setUser($user);
$comment->setPost($this->post);
if ($this->parent) {
$comment->setParent($this->parent);
}
$comment->setComment(parsetext($text));
$comment->setCommentOriginal($text);
$comment->save();
$this->curUser = $this->getUser()->getGuardUser();
if ($this->curUser) {
Cookie::setCookie($this->curUser, "comments" . $this->post->getId(), $this->post->getAllComments('count'), time() + 24 * 60 * 60);
Cookie::setCookie($this->curUser, "comments" . $this->post->getId() . "Time", date("Y-m-d H:i:s"), time() + 24 * 60 * 60);
}
}
示例8: executeIndex
public function executeIndex()
{
$response = $this->getResponse();
$response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/js/shortcuts.js'));
$response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalAdminPlugin/js/shortcuts.js'));
if (sfSympalConfig::get('check_for_upgrades_on_dashboard', null, false)) {
$this->upgrade = new sfSympalUpgradeFromWeb($this->getContext()->getConfiguration(), $this->getContext()->getEventDispatcher(), new sfFormatter());
$this->hasNewVersion = $this->upgrade->hasNewVersion();
} else {
$this->hasNewVersion = false;
}
$this->dashboardRight = new sfSympalMenu('Sympal Dashboard Right');
$numUsers = Doctrine_Core::getTable('sfGuardUser')->count();
$this->dashboardRight->addChild(sprintf('<label>Users</label> %s', $numUsers), '@sympal_users');
$numSites = Doctrine_Core::getTable('sfSympalSite')->count();
$this->dashboardRight->addChild(sprintf('<label>Sites</label> %s', $numSites), '@sympal_sites');
$numContentTypes = Doctrine_Core::getTable('sfSympalContentType')->count();
$this->dashboardRight->addChild(sprintf('<label>Content Types</label> %s', $numContentTypes), '@sympal_content_types');
$contentTypes = Doctrine::getTable('sfSympalContentType')->getAllContentTypes();
foreach ($contentTypes as $contentType) {
$numPublishedContent = Doctrine_Core::getTable('sfSympalContent')->createQuery('c')->where('c.date_published < NOW()')->andWhere('c.content_type_id = ?', $contentType->getId())->count();
$this->dashboardRight->addChild(sprintf('<label>Published %s Content</label> %s', $contentType->getLabel(), $numPublishedContent), '@sympal_content_list_type?type=' . $contentType->getId() . '&published=1');
$numUnPublishedContent = Doctrine_Core::getTable('sfSympalContent')->createQuery('c')->where('c.date_published >= NOW() OR c.date_published IS NULL')->andWhere('c.content_type_id = ?', $contentType->getId())->count();
$this->dashboardRight->addChild(sprintf('<label>Un-Published %s Content</label> %s', $contentType->getLabel(), $numUnPublishedContent), '@sympal_content_list_type?type=' . $contentType->getId() . '&published=0');
}
sfApplicationConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($this->dashboardRight, 'sympal.load_dashboard_right'));
}
示例9: get_sympal_admin_menu_object
function get_sympal_admin_menu_object($class = 'sfSympalMenuAdminMenu')
{
static $menu;
if (!$menu) {
$sympalContext = sfSympalContext::getInstance();
$menu = new $class('Sympal Admin', '@sympal_dashboard');
if ($sympalContext->isAdminModule()) {
$menu->addChild(sprintf('Go to %s', $sympalContext->getSite()->getTitle()), '@homepage', 'id=sympal_go_to_switch');
} else {
if (sfContext::getInstance()->getUser()->hasCredential('ViewDashboard')) {
$menu->addChild('Go to Admin', '@sympal_dashboard', 'id=sympal_go_to_switch');
}
}
if (sfContext::getInstance()->getUser()->hasCredential('ClearCache')) {
$menu->addChild('Clear Cache', '@sympal_clear_cache', 'id=sympal_clear_cache_fancybox');
}
$menu->addChild('Content', '@sympal_content_types_index', array('label' => 'Site Content'));
$menu->addChild('Site Administration', '@sympal_sites_edit?id=' . $sympalContext->getSite()->getId(), array('label' => 'Site Setup'));
$menu->addChild('Security', '@sympal_users', array('label' => 'Users & Security'));
$menu->addChild('Administration', '@sympal_sites', array('label' => 'Global Setup'));
sfApplicationConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($menu, 'sympal.load_admin_menu'));
$sympalContext = sfSympalContext::getInstance();
$contentRecord = $sympalContext->getCurrentContent();
$menuItem = $sympalContext->getCurrentMenuItem();
if ($contentRecord) {
sfApplicationConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($menu, 'sympal.load_editor', array('content' => $contentRecord, 'menuItem' => $menuItem)));
}
}
return $menu;
}
示例10: execute
protected function execute($arguments = array(), $options = array())
{
$pluginDir = sfApplicationConfiguration::getActive()->getPluginConfiguration('sfTwigPlugin')->getRootDir();
$helperDir = sfApplicationConfiguration::getActive()->getSymfonyLibDir() . '/helper/';
$command = sprintf('cd %s; ./helpers.sh %s', $pluginDir, $helperDir);
exec($command, $output);
echo implode(PHP_EOL, $output), "\n";
}
示例11: sendNewCommentNotification
public static function sendNewCommentNotification($fromMember, $toMember, $topicId)
{
$rootPath = sfContext::getInstance()->getRequest()->getRelativeUrlRoot();
$url = $rootPath . '/communityTopic/' . $topicId;
sfApplicationConfiguration::getActive()->loadHelpers(array('I18N'));
$message = format_number_choice('[1]1 topic has new comments|(1,Inf]%1% topics have new comments', array('%1%' => '1'), 1);
opNotificationCenter::notify($fromMember, $toMember, $message, array('category' => 'other', 'url' => $url, 'icon_url' => null));
}
示例12: checkPluginExists
/**
* Checks if a plugin exists.
*
* The plugin directory must exist and have at least one file or folder
* inside for that plugin to exist.
*
* @param string $plugin
* @param boolean $boolean Whether to throw exception if plugin exists (false) or doesn't (true)
*
* @throws sfException If the plugin does not exist
*/
public static function checkPluginExists($plugin, $boolean = true)
{
try {
sfApplicationConfiguration::getActive()->getPluginConfiguration($plugin);
return true;
} catch (Exception $e) {
return false;
}
}
示例13: save
public function save()
{
$array = $this->_buildArrayToWrite();
$this->_path = sfConfig::get('sf_app_dir') . '/config/app.yml';
file_put_contents($this->_path, sfYaml::dump($array, 4));
chdir(sfConfig::get('sf_root_dir'));
$task = new sfCacheClearTask(sfApplicationConfiguration::getActive()->getEventDispatcher(), new sfFormatter());
$task->run(array(), array('type' => 'config'));
}
示例14: checkPluginExists
/**
* Checks if a plugin exists.
*
* The plugin directory must exist and have at least one file or folder
* inside for that plugin to exist.
*
* @param string $plugin
*
* @return boolean True if the plugin exist, false otherwise
*/
protected function checkPluginExists($plugin)
{
try {
sfApplicationConfiguration::getActive()->getPluginConfiguration($plugin);
return true;
} catch (Exception $e) {
return false;
}
}
示例15: doIsEditModeCheck
/**
* Perform the check to determine if we are in edit mode or not
*
* @return void
*/
public function doIsEditModeCheck()
{
$content = sfSympalContext::getInstance()->getCurrentContent();
if ($content && $content->getPubliclyEditable() || $content && $content->getAllEditPermissions() && $this->hasCredential($content->getAllEditPermissions()) || $this->isAuthenticated() && $this->hasCredential('ManageContent')) {
$this->_isEditMode = true;
} else {
$this->_isEditMode = false;
}
$this->_isEditMode = sfApplicationConfiguration::getActive()->getEventDispatcher()->filter(new sfEvent($this, 'sympal.filter_is_edit_mode'), $this->_isEditMode)->getReturnValue();
}