protected function _initialize() { $cachePath = sfConfig::get('sf_cache_dir') . '/sympal/' . $this->_name . '.cache'; if (!file_exists($cachePath)) { $this->_loadFromSymfonyPlugins(); if ($pluginConfiguration = sfSympalPluginToolkit::isPluginDownloaded($this->_name)) { $downloadPath = sfContext::getInstance()->getConfiguration()->getPluginConfiguration($this->_name)->getRootDir(); } else { $downloadPath = sfSympalPluginToolkit::getPluginDownloadPath($this->_name); } $packageXmlPath = $downloadPath . '/package.xml'; $readmePath = $downloadPath . '/README'; if (sfSympalToolkit::fileGetContents($packageXmlPath)) { $packageXml = simplexml_load_file($packageXmlPath); } else { if (sfSympalToolkit::fileGetContents($packageXmlPath . '.tmpl')) { $packageXml = simplexml_load_file($packageXmlPath . '.tmpl'); } } if (isset($packageXml)) { $package = sfSympalPluginApi::simpleXmlToArray($packageXml); $this->_plugin = array_merge($package, $this->_plugin); } if ($readme = sfSympalToolkit::fileGetContents($readmePath)) { $this->_plugin['readme'] = $readme; } $this->_plugin['name'] = $this->_name; file_put_contents($cachePath, serialize($this->_plugin)); } else { $serialized = file_get_contents($cachePath); $this->_plugin = unserialize($serialized); } }
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; } }
public function __toString() { try { return (string) $this->render(); } catch (Exception $e) { return sfSympalToolkit::renderException($e); } }
protected function _check() { try { $this->checkFilePermissions(); sfSympalToolkit::checkRequirements(); } catch (Exception $e) { $this->getUser()->setFlash('error', $e->getMessage()); } }
/** * Render the date published for a content record * * @param sfSympalContent $content * @param string $slot * @return string $datePublished */ function render_content_date_published(sfSympalContent $content, $slot) { if ($content->date_published) { sfSympalToolkit::loadHelpers('Date'); return format_datetime($content->date_published, sfSympalConfig::get('date_published_format')); } else { return '0000-00-00'; } }
public function loadAdminMenuAssets() { sfSympalToolkit::useJQuery(); $response = sfContext::getInstance()->getResponse(); $response->addStylesheet(sfSympalConfig::getAssetPath('/sfSympalAdminPlugin/css/menu.css')); $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalAdminPlugin/js/menu.js')); $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/js/shortcuts.js')); $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalAdminPlugin/js/shortcuts.js')); $response->addStylesheet(sfSympalConfig::getAssetPath('/sfSympalPlugin/fancybox/jquery.fancybox.css')); $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/fancybox/jquery.fancybox.js')); }
protected function configure() { $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', sfSympalToolkit::getDefaultApplication()), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('search', null, sfCommandOption::PARAMETER_OPTIONAL, 'Search for a sympal plugin.'))); $this->aliases = array(); $this->namespace = 'sympal'; $this->name = 'plugin-list'; $this->briefDescription = 'List/search through all the available sympal plugins.'; $this->detailedDescription = <<<EOF The [sympal:plugin-list|INFO] is a task to list all the available sympal plugins. EOF; }
protected function configure() { $this->addArguments(array(new sfCommandArgument('name', sfCommandArgument::OPTIONAL, 'The name of the functionality. i.e. sfSympal#NAME#Plugin'))); $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', sfSympalToolkit::getDefaultApplication()), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('list-available', null, sfCommandOption::PARAMETER_NONE, 'List the available sympal plugins.'))); $this->aliases = array(); $this->namespace = 'sympal'; $this->name = 'plugin-download'; $this->briefDescription = 'Download a sympal plugin to an existing sympal installation'; $this->detailedDescription = <<<EOF The [sympal:plugin-download|INFO] is a task to download a plugin to an existing sympal installation. EOF; }
protected function configure() { $this->addArguments(array(new sfCommandArgument('name', sfCommandArgument::REQUIRED, 'The name of the functionality. i.e. sfSympal#NAME#Plugin'))); $this->addOptions(array(new sfCommandOption('content-type', null, sfCommandOption::PARAMETER_OPTIONAL, 'The name of the content type to create', null), new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', sfSympalToolkit::getDefaultApplication()), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Do not ask for confirmation'))); $this->aliases = array(); $this->namespace = 'sympal'; $this->name = 'plugin-install'; $this->briefDescription = 'Install a sympal plugin to an existing sympal installation'; $this->detailedDescription = <<<EOF The [sympal:plugin-install|INFO] is a task to install a plugin to an existing sympal installation. EOF; }
protected function configure() { $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application', sfSympalToolkit::getDefaultApplication()), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Do not ask for confirmation'), new sfCommandOption('download-new', null, sfCommandOption::PARAMETER_NONE, 'Check if a new version exists on the web and download it first before running the upgrade tasks.'))); $this->aliases = array(); $this->namespace = 'sympal'; $this->name = 'upgrade'; $this->briefDescription = 'Upgrade a Sympal project by running any new upgrade tasks.'; $this->detailedDescription = <<<EOF The [symfony sympal:upgrade|INFO] task upgrades a Sympal project by running any new upgrade tasks. [./symfony sympal:upgrade|INFO] EOF; }
protected function configure() { $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', sfSympalToolkit::getDefaultApplication()), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'))); $this->aliases = array(); $this->namespace = 'sympal'; $this->name = 'report-statistics'; $this->briefDescription = 'Report statistics back to Symfony'; $this->detailedDescription = <<<EOF The [sympal:report-statistics|INFO] task reports some statistics back to Symfony. Like what plugins you are using, versions, etc. [./sympal:report-statistics|INFO] EOF; }
protected function configure() { $this->addArguments(array(new sfCommandArgument('content-type', sfCommandArgument::REQUIRED, 'The model name to purge the data into.'))); $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', sfSympalToolkit::getDefaultApplication()), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'))); $this->aliases = array(); $this->namespace = 'sympal'; $this->name = 'purge-content'; $this->briefDescription = 'Purge the content for the specified content type.'; $this->detailedDescription = <<<EOF The [sympal:purge-content|INFO] task purges the content for the specified type. [./symfony sympal:purge-content Page|INFO] EOF; }
protected function configure() { $this->addArguments(array(new sfCommandArgument('database', sfCommandArgument::REQUIRED, 'The database to import content from.'), new sfCommandArgument('table', sfCommandArgument::REQUIRED, 'The table in the database to import content from.'), new sfCommandArgument('model', sfCommandArgument::REQUIRED, 'The model name to import the data into.'))); $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', sfSympalToolkit::getDefaultApplication()), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'))); $this->aliases = array(); $this->namespace = 'sympal'; $this->name = 'import-content'; $this->briefDescription = 'Import Sympal content from a table in a database'; $this->detailedDescription = <<<EOF The [sympal:import-content|INFO] task reports some statistics back to Symfony. Like what plugins you are using, versions, etc. [./symfony sympal:import-content my_database the_table MyContentType|INFO] EOF; }
protected function configure() { $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application', sfSympalToolkit::getDefaultApplication()), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('check', null, sfCommandOption::PARAMETER_NONE, 'Check for new versions.'))); $this->aliases = array(); $this->namespace = 'sympal'; $this->name = 'version'; $this->briefDescription = 'Show the current Sympal version and check for new versions.'; $this->detailedDescription = <<<EOF The [symfony sympal:version|INFO] task outputs the current Sympal version. [./symfony sympal:version|INFO] You can also check for new versions: [./symfony sympal:version --check|INFO] EOF; }
protected function configure() { $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application', sfSympalToolkit::getDefaultApplication()), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('all', null, sfCommandOption::PARAMETER_NONE, 'Index all applications'))); $this->aliases = array(); $this->namespace = 'sympal'; $this->name = 'build-search-index'; $this->briefDescription = 'Build the Sympal search index'; $this->detailedDescription = <<<EOF The [symfony sympal:build-search-index|INFO] task builds the search index for the first Sympal site found in the applications directory. [./symfony sympal:build-search-index|INFO] You can optionally specify an option to build all sites: [./symfony sympal:build-search-index --all|INFO] Or you can build the index for a specific site: [./symfony sympal:build-search-index --application=another_site|INFO] EOF; }
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 in the metadata plugin $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/js/jquery.metadata.js')); // Load tinymce $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/tiny_mce/tiny_mce.js')); // Load in the UI blocker $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/js/jquery.blockUI.js')); // Load the sympal editor js and css $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalEditorPlugin/js/editor.js')); $response->addStylesheet(sfSympalConfig::getAssetPath('/sfSympalEditorPlugin/css/editor.css')); // Load the js and css for the slot editing $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalEditorPlugin/js/slot.js')); $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalEditorPlugin/js/slotEditor.js')); $response->addStylesheet(sfSympalConfig::getAssetPath('/sfSympalEditorPlugin/css/slots.css')); // Fancybox $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/fancybox/jquery.fancybox.js')); $response->addStylesheet(sfSympalConfig::getAssetPath('/sfSympalPlugin/fancybox/jquery.fancybox.css')); // Ajax form submission $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/js/jQuery.form.js')); // Shortcuts $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalPlugin/js/shortcuts.js')); // Load the individual slot javsascripts // @todo The slot type javascript needs to be brought in dynamically $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalEditorPlugin/js/slots/markdown.js')); $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalEditorPlugin/js/slots/tinymce.js')); // Load the core javascript $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalEditorPlugin/js/chooser.js')); $response->addJavascript(sfSympalConfig::getAssetPath('/sfSympalEditorPlugin/js/core.js')); $this->_editorAssetsLoaded = true; } }
protected function configure() { $this->addArguments(array(new sfCommandArgument('application', sfCommandArgument::OPTIONAL, 'The application to install sympal in.', sfSympalToolkit::getDefaultApplication()))); $this->addOptions(array(new sfCommandOption('email', null, sfCommandOption::PARAMETER_OPTIONAL, 'The e-mail address of the first user to create', '*****@*****.**'), new sfCommandOption('username', null, sfCommandOption::PARAMETER_OPTIONAL, 'The username of the first user to create.', 'admin'), new sfCommandOption('password', null, sfCommandOption::PARAMETER_OPTIONAL, 'The password of the first user to create.', 'admin'), new sfCommandOption('first-name', null, sfCommandOption::PARAMETER_OPTIONAL, 'The first name of the first user to create.'), new sfCommandOption('last-name', null, sfCommandOption::PARAMETER_OPTIONAL, 'The last name of the first user to create.'), new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Do not ask for confirmation'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'))); $this->aliases = array(); $this->namespace = 'sympal'; $this->name = 'install'; $this->briefDescription = 'Install the sympal CMF into a blank symfony project'; $this->detailedDescription = <<<EOF The [./symfony sympal:install|INFO] task installs the sympal CMF into a blank symfony project: [./symfony sympal:install|INFO] By default the task will find the first application in the apps folder and install sympal for that application. You can specify the application with the first argument. [./symfony sympal:install my_app|INFO] To force a full reinstall of sympal use the force-reinstall option: [./symfony sympal:install --force-reinstall|INFO] EOF; }
/** * Autoload the helper file for a helper function * * @param string $functionName * @return void */ public static function autoloadHelper($functionName) { if (is_null(self::$_helperAutoloadCache)) { self::$_helperAutoloadCache = sfSympalContext::getInstance()->getSympalConfiguration()->getCache()->getHelperAutoload(); } if (isset(self::$_helperAutoloadCache[$functionName])) { require_once self::$_helperAutoloadCache[$functionName]; } else { throw new sfException('Could not autoload helper for function "' . $functionName . '"'); } }
public function hasCustomAction() { return $this->_get('action') || sfSympalToolkit::moduleAndActionExists($this->getModuleToRenderWith(), $this->getCustomActionName()); }
/** * Ask a for confirmation step from your actions * * @param string $title * @param string $message * @param array $variables * @return void */ public function askConfirmation($title, $message, $variables = array()) { $e = explode('/', $message); if (count($e) == 2) { try { $message = sfSympalToolkit::getSymfonyResource($e[0], $e[1], $variables); } catch (Exception $e) { throw new sfException('Invalid confirmation message: ' . $e->getMessage()); } } $request = $this->getRequest(); if ($request->hasParameter('sympal_ask_confirmation') && $request->getParameter('sympal_ask_confirmation')) { if ($request->getParameter('yes')) { return true; } else { if ($this->isAjax()) { $url = $request->getParameter('redirect_url'); $this->redirect($url . (strpos($url, '?') !== false ? '&' : '?') . 'ajax=1'); } else { $this->redirect($request->getParameter('redirect_url')); } } } else { $this->getResponse()->setTitle($title); $request->setAttribute('title', $title); $request->setAttribute('message', $message); $request->setAttribute('is_ajax', $this->isAjax()); $this->forward('sympal_default', 'ask_confirmation'); } }
/** * Delete application associated with site. * * @return null */ public function deleteApplication() { sfSympalToolkit::deleteApplication($this->slug); }
/** * Change date widgets to jquery rich date widget * * @param string $name * @param sfForm $form * @return void */ public static function changeDateWidget($name, sfForm $form) { sfSympalToolkit::useJQuery(array('ui')); sfSympalToolkit::useStylesheet('/sfSympalPlugin/css/jqueryui/jquery-ui.css'); $widgetSchema = $form->getWidgetSchema(); $widgetSchema[$name] = new sfWidgetFormJQueryDate(); }
/** * Change date widgets to jquery rich date widget * * @param string $name * @param sfForm $form * @return void */ public static function changeDateWidget($name, sfForm $form) { sfSympalToolkit::useJavascript('jquery.ui.js'); sfSympalToolkit::useStylesheet('jquery.ui.css'); $widgetSchema = $form->getWidgetSchema(); $widgetSchema[$name] = new sfWidgetFormJQueryDate(); }
<?php $app = 'sympal'; require_once dirname(__FILE__) . '/../bootstrap/unit.php'; $t = new lime_test(5, new lime_output_color()); $sympalContext = sfSympalContext::getInstance(); $menuItem = Doctrine_Core::getTable('sfSympalMenuItem')->findOneBySlug('home'); $sympalContext->setCurrentMenuItem($menuItem); $t->is($sympalContext->getCurrentMenuItem(), $menuItem); $t->is($sympalContext->getSite()->getSlug(), $app); $resource = sfSympalToolkit::getSymfonyResource('test', 'test', array('var' => 'Test')); $t->is($resource, 'Test'); $t->is(sfSympalToolkit::getDefaultApplication(), 'sympal'); $t->is(in_array('en', sfSympalToolkit::getAllLanguageCodes()), true);
/** * Shortcut helper method to use jquery in your code * * @param array $plugins Optional array of jQuery plugins to load * @return void */ function sympal_use_jquery($plugins = array()) { sfSympalToolkit::useJQuery($plugins); }
<?php foreach ($widgets as $template) { ?> <?php echo sfSympalToolkit::getSymfonyResource($template); }
<?php include_javascripts_for_form($form); include_stylesheets_for_form($form); ?> <?php echo get_sympal_slot_form_tag($form, $contentSlot); ?> <?php echo $form->renderHiddenFields(); ?> <?php echo $form->renderGlobalErrors(); ?> <div class="form_body"> <?php echo sfSympalToolkit::getSymfonyResource($contentSlot->getSlotEditFormRenderer(), array('contentSlot' => $contentSlot, 'form' => $form)); ?> </div> <input type="submit" value="<?php echo __('Save'); ?> " class="button" /> <input type="button" value="<?php echo __('Cancel'); ?> " class="button cancel" /> </form>
/** * Used by sfSympalContentSlot to render the date_published slot value * * @see sfSympalContentSlot::getValueForRendering() * @return string */ public function getDatePublishedSlotValue(sfSympalContentSlot $slot) { if ($this->date_published) { sfSympalToolkit::loadHelpers('Date'); return format_datetime($this->date_published, sfSympalConfig::get('date_published_format')); } else { return 'unpublished'; } }
public function hasCustomModule() { return $this->_get('module') || sfSympalToolkit::moduleAndActionExists($this->getCustomModuleName(), 'index'); }
public static function getPluginDownloadPath($name) { $name = self::getShortPluginName($name); $pluginName = self::getLongPluginName($name); $e = explode('.', SYMFONY_VERSION); $version = $e[0] . '.' . $e[1]; $paths = self::getDownloadablePluginPaths(); $path = ''; foreach ($paths as $pathPluginName => $path) { if ($pluginName == $pathPluginName) { $branchSvnPath = $path . '/' . $pluginName . '/branches/' . $version; $trunkSvnPath = $path . '/' . $pluginName . '/trunk'; if (sfSympalToolkit::fileGetContents($branchSvnPath) !== false || is_dir($branchSvnPath)) { $path = $branchSvnPath; break; } else { if (sfSympalToolkit::fileGetContents($trunkSvnPath) !== false || is_dir($trunkSvnPath)) { $path = $trunkSvnPath; break; } else { if (is_dir($path)) { break; } } } } } if ($path) { return $path; } else { throw new sfException('Could not find download path for ' . $pluginName); } }