当前位置: 首页>>代码示例>>PHP>>正文


PHP sfSympalConfig类代码示例

本文整理汇总了PHP中sfSympalConfig的典型用法代码示例。如果您正苦于以下问题:PHP sfSympalConfig类的具体用法?PHP sfSympalConfig怎么用?PHP sfSympalConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了sfSympalConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _parseSyntaxes

 /**
  * Searches through the content and extracts out any matches. The return
  * value is a formatted array of what needs to be replaced
  * 
  * Returned syntax will look like this:
  *   array(
  *     'link' => array(
  *       3 => array('options' => array(), 'replace' => '[link:3]'),
  *       5 => array('options' => array('option' => 'value'), 'replace' => '[link:5 option=value]'),
  *     ), asset => array(
  *       10 => array('options' => array(), 'replace' => '[asset:10]'),
  *     ),
  *   )
  * 
  * @return array
  */
 private function _parseSyntaxes($content)
 {
     // create the replacement string (e.g. link|asset|myObject)
     $replacementString = implode('|', array_keys(sfSympalConfig::get('content_syntax_types')));
     preg_match_all("/\\[({$replacementString}):(.*?)\\]/", $content, $matches);
     if (isset($matches[0]) && $matches[0]) {
         $replacements = array();
         $types = $matches[1];
         $bodies = $matches[2];
         foreach ($types as $type) {
             $replacements[$type] = array();
         }
         /*
          * body matches (e.g. "3" or "5 option=value")
          */
         foreach ($bodies as $key => $body) {
             // use the key to find the corresponding type
             $typeKey = $types[$key];
             $e = explode(' ', $body);
             $slug = $e[0];
             $replacements[$typeKey][$slug] = array('options' => _parse_attributes(substr($body, strlen($e[0]))), 'replace' => $matches[0][$key]);
         }
         return $replacements;
     } else {
         return false;
     }
 }
开发者ID:slemoigne,项目名称:sympal,代码行数:43,代码来源:sfSympalContentReplacer.class.php

示例2: _getForm

 /**
  * Returns the config form and checks the file permissions
  * 
  * @return sfSympalConfigForm
  */
 protected function _getForm()
 {
     $this->checkFilePermissions();
     $class = sfSympalConfig::get('config_form_class', null, 'sfSympalConfigForm');
     $this->form = new $class();
     return $this->form;
 }
开发者ID:sympal,项目名称:sympal,代码行数:12,代码来源:Basesympal_configActions.class.php

示例3: enableSympalResultCache

 /**
  * Enable Sympal result cache for this query if it is enabled via configuration
  *
  * @param string $key 
  * @return Doctrine_Query $query
  */
 public function enableSympalResultCache($key)
 {
     if ($lifetime = sfSympalConfig::shouldUseResultCache($key)) {
         $this->useResultCache(true, $lifetime, $key);
     }
     return $this;
 }
开发者ID:sympal,项目名称:sympal,代码行数:13,代码来源:sfSympalDoctrineQuery.class.php

示例4: uninstall

 public function uninstall($delete = null)
 {
     if ($delete !== null) {
         $this->setOption('delete_plugin_files', $delete);
     }
     $this->logSection('sympal', sprintf('Uninstalling Sympal plugin named "%s"', $this->_pluginName));
     if ($this->hasModels()) {
         if ($this->getOption('build_all_classes')) {
             $this->_buildAllClasses();
         }
         if ($this->getOption('delete_related_data')) {
             $this->_deleteRelatedData();
         }
         if ($this->getOption('delete_other_data')) {
             $this->_deleteOtherData();
         }
         if ($this->getOption('drop_database_tables')) {
             $this->_dropDatabaseTables();
         }
     }
     if ($this->getOption('run_custom_install')) {
         $this->_runCustomUninstall();
     }
     if ($this->getOption('delete_plugin_files')) {
         $this->_deletePluginFiles();
     }
     if ($this->getOption('publish_assets')) {
         $this->_publishAssets();
     }
     $this->_clearCache();
     sfSympalConfig::writeSetting($this->_pluginName, 'installed', false);
 }
开发者ID:sympal,项目名称:sympal,代码行数:32,代码来源:sfSympalPluginManagerUninstall.class.php

示例5: __construct

 /**
  * Instantiate the sfSympalCache instance and prime the cache for this Sympal
  * project
  *
  * @see sfSympalConfiguration
  * @see sfSympalPluginConfiguration
  * @param sfSympalConfiguration $sympalConfiguration
  */
 public function __construct(sfSympalConfiguration $sympalConfiguration)
 {
     $this->_sympalConfiguration = $sympalConfiguration;
     $this->_projectConfiguration = $sympalConfiguration->getProjectConfiguration();
     $this->_cacheDriver = call_user_func_array(sfSympalConfig::get('get_cache_driver_callback'), array($this));
     $this->primeCache();
 }
开发者ID:slemoigne,项目名称:sympal,代码行数:15,代码来源:sfSympalCache.class.php

示例6: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     foreach ($arguments['configure'] as $value) {
         list($key, $value) = explode('=', $value);
         $e = explode('.', $key);
         $group = isset($e[1]) ? $e[0] : null;
         $key = isset($e[1]) ? $e[1] : $e[0];
         $value = is_numeric($value) ? (int) $value : $value;
         $value = $value == 'false' ? false : $value;
         $value = $value == 'true' ? true : $value;
         $infoValue = $value;
         if (in_array(substr($value, 0, 1), array('[', '{'))) {
             $value = sfYamlInline::load($value);
             $infoValue = 'YAML: ' . $infoValue;
         }
         $writeToApp = isset($options['application']) && $options['application'] ? true : false;
         if ($group) {
             $this->logSection('sympal', sprintf('Writing setting "%s" with a value of "%s" under the "%s" group.', $key, $infoValue, $group));
             sfSympalConfig::writeSetting($group, $key, $value, $writeToApp);
         } else {
             $this->logSection('sympal', sprintf('Writing setting "%s" with a value of "%s".', $key, $infoValue, $group));
             sfSympalConfig::writeSetting($key, $value, null, $writeToApp);
         }
     }
 }
开发者ID:sympal,项目名称:sympal,代码行数:28,代码来源:sfSympalConfigureTask.class.php

示例7: executeSlot_save

 /**
  * Handles the form submit for a given slot. This could come from two sources:
  *   1) Inline, frontend editing. (ajax request)
  *   2) Admin, non-inline editing (non-ajax request)
  */
 public function executeSlot_save(sfWebRequest $request)
 {
     $this->contentSlot = $this->setupContentSlot($request);
     $this->form = $this->contentSlot->getEditForm();
     $this->form->bind($request->getParameter($this->form->getName()));
     if ($this->form->isValid()) {
         $this->form->save();
         $this->getUser()->setFlash('saved', __('Slot saved'), false);
         // if we close editor on save, just return the flash js and the editor close js
         if ($request->isXmlHttpRequest() && sfSympalConfig::get('inline_editing', 'close_editor_on_save', false)) {
             $this->getContext()->getConfiguration()->loadHelpers('SympalContentSlotEditor');
             $this->renderText(trigger_flash_from_user($this->getUser()));
             $this->renderText(sprintf('
     <script type="text/javascript">
       $(document).ready(function() {
         $("#sympal_slot_wrapper_%s").sympalSlot("closeEditor");
       });
     </script>
     ', $this->contentSlot->id));
             return sfView::NONE;
         }
     } else {
         $this->getUser()->setFlash('error', __('There was an error saving your slot'), false);
     }
     // we need to route the response appropriately based on ajax/non-ajax
     if ($request->isXmlHttpRequest()) {
         // ajax, just re-show the form
         $this->renderPartial('sympal_edit_slot/slot_editor_form');
     } else {
         // handle non-ajax, which come from sympal_content/edit_slots
         // this is a bit of a hack, we redirect even on errors, which is technically a fail
         $this->redirect('@sympal_content_edit_slots?id=' . $this->contentSlot->getContentRenderedFor()->id);
     }
     return sfView::NONE;
 }
开发者ID:sympal,项目名称:sympal,代码行数:40,代码来源:Basesympal_edit_slotActions.class.php

示例8: loadEditorAssets

 public function loadEditorAssets()
 {
     if (!$this->_editorAssetsLoaded) {
         $this->configuration->loadHelpers('SympalContentSlotEditor');
         sfSympalToolkit::useJQuery(array('ui'));
         $response = sfContext::getInstance()->getResponse();
         // Load jquery tools/plugins that the inline editor requires
         $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/js/jQuery.cookie.js'));
         $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/js/jQuery.elastic.js'));
         $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/js/jquery.Jcrop.min.js'));
         // Load markitup markdown editor
         if (sfSympalConfig::get('enable_markdown_editor')) {
             $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/markitup/jquery.markitup.js'));
             $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/markitup/sets/markdown/set.js'));
             $response->addStylesheet(sfSympalConfig::getAssetPath('/sfSympalPlugin/markitup/skins/markitup/style.css'));
             $response->addStylesheet(sfSympalConfig::getAssetPath('/sfSympalPlugin/markitup/sets/markdown/style.css'));
         }
         // Load tinymce
         $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/tiny_mce/tiny_mce.js'));
         // Load the sympal editor js and css
         $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalEditorPlugin/js/editor.js'));
         $response->addStylesheet(sfSympalConfig::getAssetPath('/sfSympalEditorPlugin/css/editor.css'));
         // Fancybox
         $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/fancybox/jquery.fancybox.js'));
         $response->addStylesheet(sfSympalConfig::getAssetPath('/sfSympalPlugin/fancybox/jquery.fancybox.css'));
         // Shortcuts
         $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/js/shortcuts.js'));
         $this->_editorAssetsLoaded = true;
     }
 }
开发者ID:slemoigne,项目名称:sympal,代码行数:30,代码来源:sfSympalEditorPluginConfiguration.class.php

示例9: _checkInstalled

 /**
  * Check if Sympal is installed and redirect to installer if not.
  * Do some other install checks as well.
  *
  * @return void
  */
 private function _checkInstalled()
 {
     $request = $this->_symfonyContext->getRequest();
     // Prepare the symfony application if it has not been prepared yet
     if (!$this->_symfonyContext->getUser() instanceof sfSympalUser) {
         chdir(sfConfig::get('sf_root_dir'));
         $task = new sfSympalEnableForAppTask($this->_dispatcher, new sfFormatter());
         $task->run(array($this->_invoker->getProjectConfiguration()->getApplication()), array());
         $this->_symfonyContext->getController()->redirect('@homepage');
     }
     /*
      * Redirect to install module if...
      *   * not in test environment
      *   * sympal has not been installed
      *   * module is not already sympal_install
      */
     if (sfConfig::get('sf_environment') != 'test' && !sfSympalConfig::get('installed') && $request->getParameter('module') != 'sympal_install') {
         $this->_symfonyContext->getController()->redirect('@sympal_install');
     }
     /*
      * Redirect to homepage if no site record exists so we can prompt the
      * user to create a site record for this application.
      * 
      * This check is only ran in dev mode
      */
     if (sfConfig::get('sf_environment') == 'dev' && !$this->_sympalContext->getSite() && $this->_symfonyContext->getRequest()->getPathInfo() != '/') {
         $this->_symfonyContext->getController()->redirect('@homepage');
     }
 }
开发者ID:sympal,项目名称:sympal,代码行数:35,代码来源:sfSympalContextLoadFactoriesListener.class.php

示例10: install

 public function install()
 {
     if ($this->getOption('uninstall_first')) {
         $uninstall = new sfSympalPluginManagerUninstall($this->_pluginName, $this->_configuration, $this->_formatter);
         $uninstall->setOption('publish_assets', false);
         $uninstall->uninstall();
     }
     $this->logSection('sympal', sprintf('Installing Sympal plugin named "%s"', $this->_pluginName));
     try {
         if ($this->getOption('create_tables')) {
             $this->_createDatabaseTables();
         }
         if ($this->getOption('load_data')) {
             $this->_loadData();
         }
         if ($this->getOption('publish_assets')) {
             $this->_publishAssets();
         }
         if ($this->getOption('clear_cache')) {
             $this->_clearCache();
         }
         sfSympalConfig::writeSetting($this->_pluginName, 'installed', true);
     } catch (Exception $e) {
         $uninstall = new sfSympalPluginManagerUninstall($this->_pluginName, $this->_configuration);
         $uninstall->uninstall();
         throw $e;
     }
 }
开发者ID:sympal,项目名称:sympal,代码行数:28,代码来源:sfSympalPluginManagerInstall.class.php

示例11: getEmbed

    public function getEmbed($options = array())
    {
        $url = $this->getUrl();
        $width = isset($options['width']) ? $options['width'] : sfSympalConfig::get('default_video_width', null, 400);
        $height = isset($options['height']) ? $options['height'] : sfSympalConfig::get('default_video_height', null, 400);
        $extension = $this->getExtension();
        $id = $this->getDoctrineAsset()->getId();
        if ($extension == 'swf') {
            return sprintf('<object width="%s" height="%s">
<param name="movie" value="%s">
<embed src="%s" width="%s" height="%s">
</embed>
</object>', $width, $height, $url, $url, $width, $height);
        } else {
            if ($extension == 'flv') {
                sympal_use_jquery();
                sympal_use_javascript('/sfSympalPlugin/js/flowplayer.min.js');
                return sprintf('<a href="%s" style="display:block;width:%spx;height:%spx;" id="asset_%s"></a>
<script language="JavaScript"> 
    flowplayer("asset_%s", "%s"); 
</script>', $url, $width, $height, $id, $id, _compute_public_path('/sfSympalPlugin/js/flowplayer.swf', 'swf', 'swf'));
            } else {
                return $this->getLink($options);
            }
        }
    }
开发者ID:sympal,项目名称:sympal,代码行数:26,代码来源:sfSympalAssetVideoObject.class.php

示例12: get_sympal_content_slot_editor

/**
 * Renders an edit form for a slot
 * 
 * @param sfSympalContent $content The content on which the slot should be rendered
 * @param sfSympalContentSlot $slot The slot to render in a form
 * @param array $options An options array. Available options include:
 *   * edit_mode
 * 
 */
function get_sympal_content_slot_editor($content, $slot, $options = array())
{
    $slot->setContentRenderedFor($content);
    // merge in some global default slot options
    $options = array_merge(array('edit_mode' => sfSympalConfig::get('inline_editing', 'default_edit_mode'), 'view_url' => url_for('sympal_content_slot_view', array('id' => $slot->id, 'content_id' => $slot->getContentRenderedFor()->id))), $options);
    // merge the default config for this slot into the given config
    $slotOptions = sfSympalConfig::get($slot->getContentRenderedFor()->Type->slug, 'content_slots', array());
    if (isset($slotOptions[$slot->name])) {
        $options = array_merge($slotOptions[$slot->name], $options);
    }
    /*
     * Finally, override the "type" option, it should be set to whatever's
     * in the database, regardless of what the original slot options were
     */
    $options['type'] = $slot->type;
    /*
     * Give the slot a default value if it's blank.
     * 
     * @todo Move this somewhere where it can be specified on a type-by-type
     * basis (e.g., if we had an "image" content slot, it might say
     * "Click to choose image"
     */
    $renderedValue = $slot->render();
    if (!$renderedValue) {
        $renderedValue = __('[Hover over and click edit to change.]');
    }
    $inlineContent = sprintf('<a href="%s" class="sympal_slot_button">' . __('Edit') . '</a>', url_for('sympal_content_slot_form', array('id' => $slot->id, 'content_id' => $slot->getContentRenderedFor()->id)));
    $inlineContent .= sprintf('<span class="sympal_slot_content">%s</span>', $renderedValue);
    return sprintf('<span class="sympal_slot_wrapper %s" id="sympal_slot_wrapper_%s">%s</span>', htmlentities(json_encode($options)), $slot->id, $inlineContent);
}
开发者ID:RafalJachimczyk,项目名称:sympal,代码行数:39,代码来源:SympalContentSlotEditorHelper.php

示例13: setup

 public function setup()
 {
     parent::setup();
     $q = Doctrine_Query::create()->from('sfSympalMenuItem m');
     if ($this->object->exists()) {
         $q->andWhere('m.id != ?', $this->object->id);
     }
     if (sfSympalConfig::isI18nEnabled('sfSympalMenuItem')) {
         $q->leftJoin('m.Translation mt');
     }
     $q->andWhere('m.site_id = ?', sfSympalContext::getInstance()->getService('site_manager')->getSite()->getId());
     $this->widgetSchema['parent_id'] = new sfWidgetFormDoctrineChoice(array('model' => 'sfSympalMenuItem', 'add_empty' => __('~ (object is at root level)'), 'order_by' => array('root_id, lft', ''), 'query' => $q, 'method' => 'getIndentedName'));
     $this->validatorSchema['parent_id'] = new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'sfSympalMenuItem'));
     $this->setDefault('parent_id', $this->object->getParentId());
     $this->widgetSchema->setLabel('parent_id', 'Child of');
     $this->widgetSchema['move'] = new sfWidgetFormDoctrineChoice(array('model' => 'sfSympalMenuItem', 'add_empty' => true, 'order_by' => array('root_id, lft', ''), 'query' => $q, 'method' => 'getIndentedName'));
     $this->validatorSchema['move'] = new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'sfSympalMenuItem'));
     $this->widgetSchema->setLabel('move', 'Position menu item');
     $choices = array('' => '', 'Prev' => 'Before', 'Next' => 'After');
     $this->widgetSchema['where_to_move'] = new sfWidgetFormChoice(array('choices' => $choices));
     $this->validatorSchema['where_to_move'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys($choices)));
     $this->widgetSchema->setLabel('where_to_move', 'Position before or after?');
     unset($this['site_id'], $this['Content'], $this['root_id'], $this['lft'], $this['rgt'], $this['level']);
     $this->validatorSchema['slug']->setOption('required', true);
 }
开发者ID:sympal,项目名称:sympal,代码行数:25,代码来源:PluginsfSympalMenuItemForm.class.php

示例14: run

    public function run(sfEvent $event, $content)
    {
        // The following were removed, but should probably be there
        //$request->isXmlHttpRequest()
        //$controller->getRenderMode() != sfView::RENDER_CLIENT ||
        $response = $event->getSubject();
        if (strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || in_array($response->getStatusCode(), array(302, 301)) || $response->isHeaderOnly()) {
            return $content;
        }
        if ($code = sfSympalConfig::get('google_analytics_code')) {
            $js = <<<EOF
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
\tdocument.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
\tvar pageTracker = _gat._getTracker("{$code}");
\tpageTracker._trackPageview();
} catch(err) {}</script>
EOF;
            return str_replace('</body>', $js . '</body>', $content);
        } else {
            return $content;
        }
    }
开发者ID:sympal,项目名称:sympal,代码行数:26,代码来源:sfSympalRenderingResponseFilterContentListener.class.php

示例15: executeCreate_asset

 public function executeCreate_asset(sfWebRequest $request)
 {
     $form = new sfSympalAssetUploadForm();
     $upload = $request->getParameter($form->getName());
     $form->setUploadDirectory($upload['directory']);
     $form->bind($upload, $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $postFile = $form->getValue('file');
         $fileName = $postFile->getOriginalName();
         $name = Doctrine_Inflector::urlize(sfSympalAssetToolkit::getNameFromFile($fileName));
         $extension = pathinfo($fileName, PATHINFO_EXTENSION);
         $fullName = $extension ? $name . '.' . $extension : $name;
         $destinationDirectory = sfConfig::get('sf_web_dir') . '/' . sfSympalConfig::get('assets', 'root_dir') . $upload['directory'];
         $this->getUser()->setFlash('notice', 'File uploaded successfully.');
         $postFile->save($destinationDirectory . '/' . $fullName);
         $assetObject = sfSympalAssetToolkit::createAssetObject($upload['directory'] . '/' . $fullName);
         if (!($asset = $assetObject->getDoctrineAsset())) {
             $asset = new sfSympalAsset();
         }
         $asset->path = $assetObject->getRelativePathDirectory();
         $asset->name = $assetObject->getName();
         $asset->save();
     } else {
         $this->getUser()->setFlash('error', 'Could not upload file.');
     }
     if ($this->isAjax) {
         $this->redirect('@sympal_assets_select?is_ajax=' . $this->isAjax . '&dir=' . $upload['directory']);
     } else {
         $this->redirect('@sympal_assets?is_ajax=' . $this->isAjax . '&dir=' . $upload['directory']);
     }
 }
开发者ID:RafalJachimczyk,项目名称:sympal,代码行数:31,代码来源:Basesympal_assetsActions.class.php


注:本文中的sfSympalConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。