/** * checkSymfonyVersion - checks if symfony version used is compatible with the * plugin, and detect whether routes are new style (using sfRoute objects) or * old style. * * @return void */ protected static function checkSymfonyVersion() { if (defined('SYMFONY_VERSION')) { list($sfVersionMajor, $sfVersionMinor, $sfVersionRelease) = explode('.', SYMFONY_VERSION); if ($sfVersionMajor != 1 || !in_array($sfVersionMinor, array(2, 3, 4))) { throw new sfConfigurationException(self::PLUGIN_NAME . ' needs symfony 1.2 to 1.4 to run.'); } self::$newStyleRoutes = (bool) ($sfVersionMinor > 1); } else { throw new sfConfigurationException(self::PLUGIN_NAME . ' needs symfony 1.2 to 1.4 to run, but no version were found.'); } }
public function getPanelContent() { $controller = sfContext::getInstance()->getController(); try { $html = ' <style type="text/css"> div#sfWebDebugDynamics table ul, div#sfWebDebugDynamics table ul li { margin: 0; padding: 0; list-style-type: dash; } div#sfWebDebugDynamics table ul { padding-left: 16px; } </style> <table class="sfWebDebugLogs"> <tr> <td> </td> <th>Javascript items</th> <th>Generated javascript</th> <th>Stylesheet items</th> <th>Generated stylesheet</th> </tr>' . "\n"; $line_nb = 0; $manager = sfDynamics::getManager(); foreach ($manager->getPackages() as $packageName => $package) { $html .= '<tr>'; $html .= '<th>' . $packageName . '</th>'; foreach (array('Javascripts' => 'js', 'Stylesheets' => 'css') as $assetType => $extension) { if ($package->{'has' . $assetType}()) { $html .= '<td>'; $html .= '<ul>'; foreach ($package->{'get' . $assetType}() as $javascript) { $html .= '<li>' . $javascript . '</li>'; } $html .= '</ul>'; $html .= '</td>'; $html .= '<td>'; $url = $controller->genUrl(sfDynamicsRouting::uri_for($packageName, $extension)); $html .= sprintf('<a href="%s" target="_blank">%s</a>', $url, basename($url)); $html .= '</td>'; } else { $html .= '<td colspan="2" align="center">not available</td>'; } } $html .= '</tr>'; } $html .= '</table><br />'; } catch (Exception $e) { $html = ' <div> An exception occured while trying to render debug information for loaded packages. <br /><br /> This may have happened because your current application is not ready to use sfDynamics. Please read the exception detail to understand the problem. <br /><br /> <b>Check-list</b>: <ul> <li>make sure %sf_web_dir%/dynamics/ exists and is writable by your web-server user.</li> <li>make sure sfDynamicsPlugin is activated in %sf_root_dir%/config/ProjectConfiguration.class.php</li> <li>make sure sfDynamics module is enabled in your current application\'s settings.yml file.</li> </ul> </div> <br /> '; } return '<div id="sfWebDebugDynamics">' . $html . '</div>'; }
public function generateAssetsHtml() { $renderer = sfDynamics::getRenderer(); $html = ''; /* generate useable package array */ $packages = array(); foreach (array_keys($this->packages) as $packageName) { $packages[$packageName] = $this->getPackage($packageName); } foreach (array('javascript' => 'js', 'stylesheet' => 'css') as $type => $ext) { $assets = $this->{$type . 's'}; if (sfDynamicsConfig::isGroupingEnabledFor($type) && sfDynamicsConfig::isSupercacheEnabled()) { $url = sfDynamicsRouting::supercache_for($packages, $ext); $renderer->generateSupercache($url, $packages, $assets, $type); $html .= ' ' . $this->getTag($url, $type) . "\n"; } else { foreach ($assets as $asset) { $url = $this->controller->genUrl(sfDynamicsRouting::uri_for($asset, $ext)); $html .= ' ' . $this->getTag($url, $type) . "\n"; } } } return $html; }
/** * Generate the sfDynamics html tags for a given asset type */ protected function generateHtml($type, $ext) { if (!isset($this->{$type . 's'})) { throw new sfDynamicsException('The ' . $type . ' asset type is unknown'); } $renderer = sfDynamics::getRenderer(); $html = ''; /* generate useable package array */ $packages = array(); foreach (array_keys($this->packages) as $packageName) { $packages[$packageName] = $this->getPackage($packageName); } $assets = $this->{$type . 's'}; if (sfDynamicsConfig::isGroupingEnabledFor($type) && sfDynamicsConfig::isSupercacheEnabled()) { $url = sfDynamicsRouting::supercache_for($packages, $ext); $renderer->generateSupercache($url, $packages, $assets, $type); $url = call_user_func(array('sfDynamicsConfig', 'get' . ucfirst($ext) . 'Cdn')) . $url; $html .= ' ' . $this->getTag($url, $type) . "\n"; } else { foreach ($assets as $asset) { $url = $this->controller->genUrl(sfDynamicsRouting::uri_for($asset, $ext)); $url = call_user_func(array('sfDynamicsConfig', 'get' . ucfirst($ext) . 'Cdn')) . $url; $html .= ' ' . $this->getTag($url, $type) . "\n"; } } return $html; }