public function preRender() { if (Zend_Auth::getInstance()->hasIdentity()) { $controller = sgContext::getInstance()->getController(); if ($controller instanceof FlatCMSPluginController) { $session = new Zend_Session_Namespace(Zend_Auth::getInstance()->getStorage()->getNamespace()); $session->FlatCMSEditorPluginFileMTime = filemtime(FlatCMSPluginPageModel::getPagePath(sgContext::getInstance()->getCurrentPath())); //figure out better way to handle this so libraries aren't double loaded $controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/jquery.min.js'); $controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/jquery.jeditable.mini.js'); $controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/jquery.jeditable.autogrow.js'); $controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/tinymce/jscripts/tiny_mce/jquery.tinymce.js'); $controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/jquery.jeditable.tinymce.js'); $controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/init.js'); $controller->js_settings['FlatCMSEditorPlugin'] = array('saveURL' => sgToolkit::url(sgConfiguration::get('routing.FlatCMSEditorPlugin_save.path')), 'currentPath' => sgContext::getInstance()->getCurrentPath()); if (isset($controller->content) && is_array($controller->content)) { $textarea_fields = sgConfiguration::get('settings.FlatCMSEditorPlugin.textarea_fields', array()); foreach ($controller->content as $key => &$field) { if (in_array($key, $textarea_fields)) { $field = '<div class="editable-area" id="' . $key . '">' . $field . '</div>'; } else { $field = '<div class="editable" id="' . $key . '">' . $field . '</div>'; } } } } } }
public function executeCoreFixPerms($arguments, $options) { $path = realpath(sgContext::getInstance()->getRootDir() . '/cache/'); chmod($path, 0777); $files = sgToolkit::getFiles($path); sgToolkit::chmod($files, 0777); }
public static function getPath($pathName) { if (isset(self::$paths[$pathName])) { return sgContext::getInstance()->getRootDir() . self::$paths[$pathName]; } return false; }
public function getTemplateVars() { $templateVars = get_object_vars($this); unset($templateVars['twig']); $templateVars['context'] = sgContext::getInstance(); $templateVars['request'] = array('uri' => $_SERVER['REQUEST_URI'], 'method' => $_SERVER['REQUEST_METHOD'], 'ajax' => sgContext::isAjaxRequest(), 'vars' => array('GET' => $_GET, 'POST' => $_POST)); return $templateVars; }
public final function execute($namespace, $task, $cliParams = array()) { //special case for init-project if ("{$namespace}:{$task}" !== 'core:init-project' && "{$namespace}:{$task}" !== 'core:help') { if (!file_exists(sgContext::getInstance()->getRootDir() . '/config/ProjectConfiguration.class.php')) { sgCLI::error("Task \"{$namespace}:{$task}\" can only be executed in a project directory."); return false; } } if ($params = $this->parseParams($namespace, $task, $cliParams)) { $executeMethod = sgToolkit::camelCase("execute {$namespace} {$task}"); $this->{$executeMethod}($params['arguments'], $params['options']); return true; } return false; }
public static function dispatch($route, $method, $matches) { sgContext::setCurrentRoute($route); if (isset($route['disabled']) && $route['disabled'] == true) { if (sgConfiguration::get('settings.debug')) { exit('<pre>Route "' . $route['name'] . '" is disabled.' . "\n</pre>"); } $obj = new sgBaseController($matches); sgContext::getInstance()->setController($obj); print $obj->throwErrorCode('404'); } else { $plugins = sgConfiguration::getInstance()->getPlugins(); foreach ($plugins as $plugin) { if (isset($plugin->configuration)) { sgToolkit::executeMethod($plugin->configuration, 'preExecute'); } } sgToolkit::executeMethod(sgConfiguration::getInstance(), 'preExecute'); if (isset($route['class'])) { if (class_exists($route['class'])) { $obj = new $route['class']($matches); sgContext::getInstance()->setController($obj); if (method_exists($obj, $method)) { sgToolkit::executeMethod($obj, 'preExecute'); print $obj->{$method}(); sgToolkit::executeMethod($obj, 'postExecute'); } else { throw new BadMethodCallException("Method, {$method}, not supported"); } } else { throw new Exception('Class, ' . $route['class'] . ', not found'); } } else { $obj = new sgBaseController($matches); sgContext::getInstance()->setController($obj); sgToolkit::executeMethod($obj, 'preExecute'); print $obj->{$method}(); sgToolkit::executeMethod($obj, 'postExecute'); } sgToolkit::executeMethod(sgConfiguration::getInstance(), 'postExecute'); foreach ($plugins as $plugin) { if (isset($plugin->configuration)) { sgToolkit::executeMethod($plugin->configuration, 'postExecute'); } } } }
public function getTemplateVars() { $templateVars = get_object_vars($this); $templateVars['context'] = sgContext::getInstance(); $templateVars['configuration'] = sgConfiguration::getInstance(); $templateVars['request'] = array('uri' => $_SERVER['REQUEST_URI'], 'method' => $_SERVER['REQUEST_METHOD'], 'ajax' => sgContext::isAjaxRequest(), 'vars' => array('GET' => $_GET, 'POST' => $_POST)); $templateVars['js_settings'] = json_encode($this->js_settings); //str_replace() needed for incorrect slash escaping in php 5.2 $js_settings = str_replace('\\/', '/', json_encode($this->js_settings)); $templateVars['js_settings'] = <<<END <script type="text/javascript" charset="utf-8"> <!--//--><![CDATA[//><!-- superglue = new Object(); superglue.settings = {$js_settings}; //--><!]]> </script> END; return $templateVars; }
private function __construct() { sgContext::getInstance()->setRootDir(self::getRootDir()); sgContext::getInstance()->setLibDir(self::getLibDir()); self::loadConfig('settings', dirname(__FILE__) . '/config/config.php'); self::_initPlugins(dirname(__FILE__), self::get('settings.enabled_plugins')); //init core plugins $projectConfig = null; if (file_exists(realpath(sgContext::getInstance()->getRootDir() . '/config/config.php'))) { $projectConfig = (include realpath(sgContext::getInstance()->getRootDir() . '/config/config.php')); if (isset($projectConfig['enabled_plugins'])) { self::_initPlugins(sgContext::getInstance()->getRootDir(), $projectConfig['enabled_plugins']); //init project plugins } self::loadConfigFromArray('settings', $projectConfig); } if (file_exists(realpath(sgContext::getInstance()->getRootDir() . '/config/routing.php'))) { self::loadConfig('routing', sgContext::getInstance()->getRootDir() . '/config/routing.php'); } self::_initAutoloader(); self::_initPluginConfigurations(); $this->init(); return; }
<?php return array('FlatCMSPlugin' => array('data_dir' => sgContext::getInstance()->getRootDir() . '/data/flatcms'));
<?php return array('ZendAuthPlugin' => array('zend_lib_path' => sgContext::getInstance()->getRootDir() . '/lib/vendor', 'passwd_path' => sgContext::getInstance()->getRootDir() . '/data/ZendAuthPlugin.passwd'));