Ejemplo n.º 1
0
define('APPLICATION_DIRECTORY', dirname(__FILE__));
ini_set("include_path", ini_get("include_path") . PATH_SEPARATOR . APPLICATION_DIRECTORY);
require "Joobsbox/Application/Development.php";
require "config/config.php";
require "config/router.php";
require "config/viewRenderer.php";
Zend_Controller_Front::getInstance()->setControllerDirectory(APPLICATION_DIRECTORY . '/Joobsbox/Controllers');
Zend_Registry::set("PluginLoader", new Joobsbox_Plugin_Loader());
Zend_Registry::set("EventHelper", new Joobsbox_Helpers_Event());
Zend_Registry::set("FilterHelper", new Joobsbox_Helpers_Filter());
Zend_Registry::set("TranslationHelper", new Joobsbox_Helpers_TranslationHash());
Zend_Registry::get("TranslationHelper")->regenerateHash();
require "Joobsbox/Application/ErrorHandler.php";
Zend_Controller_Action_HelperBroker::addPath(APPLICATION_DIRECTORY . '/Joobsbox/Helpers', 'Joobsbox_Helpers');
if (!isset($testing)) {
    $front = Zend_Controller_Front::getInstance();
    $front->setBaseUrl(BASE_URL)->setParam('disableOutputBuffering', true)->registerPlugin(new Joobsbox_Plugin_Controller());
    configureTheme();
    if (isset($joobsbox_render_var)) {
        setLayout('integration');
        if (isset($joobsbox_integration_text)) {
            $viewRenderer->view->integrationText = $joobsbox_integration_text;
        }
        $front->returnResponse(true);
    }
    Zend_Registry::get("EventHelper")->fireEvent("joobsbox_init");
    $response = $front->dispatch();
    if (isset($joobsbox_render_var)) {
        $joobsbox_render_var = $response->getBody();
    }
}
Ejemplo n.º 2
0
function setLayout($layout)
{
    configureTheme(APPLICATION_THEME, $layout);
}
 public function step2Action()
 {
     $this->reloadConfig();
     configureTheme(APPLICATION_THEME, 'install');
     $session = new Zend_Session_Namespace('Install');
     // Create tables
     $xmlSchema = ezcDbSchema::createFromFile('xml', APPLICATION_DIRECTORY . '/data/schema.xml');
     $schema =& $xmlSchema->getSchema();
     if ($this->config->db->prefix != "") {
         $keys = array_keys($schema);
         foreach ($keys as $tableName) {
             $schema[$this->config->db->prefix . $tableName] = clone $schema[$tableName];
             unset($schema[$tableName]);
         }
     }
     $dbconfig = new Zend_Config_Xml(DB_CONFIG_LOCATION, 'zend_db');
     $db = ezcDbFactory::create($dbconfig->connection_string);
     $xmlSchema->writeToDb($db);
     $db = Zend_Registry::get("db");
     $db->delete($this->config->db->prefix . $this->config->dbtables->categories, array("name='General'"));
     $db->insert($this->config->db->prefix . $this->config->dbtables->categories, array('id' => 0, 'name' => 'General', 'link' => 'general', 'orderindex' => 100, 'parent' => 0));
     // Make the form
     $this->adminForm = new Zend_Form();
     $this->adminForm->setAction($this->view->baseUrl . "/install/step2")->setMethod('post')->setLegend('Administrator credentials');
     $notEmpty = new Zend_Validate_NotEmpty();
     $realname = $this->adminForm->createElement('text', 'realname')->setLabel('Your name:')->addFilter('StripTags')->addFilter('StringTrim')->addFilter('HtmlEntities')->setAttrib('class', 'validate[required]')->addValidator($notEmpty->setMessage($this->view->translate("Real name is mandatory")))->setRequired(true);
     $notEmpty = clone $notEmpty;
     $username = $this->adminForm->createElement('text', 'username')->setLabel('Username:'******'StripTags')->addFilter('StringTrim')->addFilter('HtmlEntities')->setAttrib('class', 'validate[required]')->addValidator($notEmpty->setMessage($this->view->translate("Username is mandatory")))->setRequired(true);
     $notEmpty = clone $notEmpty;
     $password = $this->adminForm->createElement('text', 'password')->setLabel('Password:'******'StripTags')->addFilter('StringTrim')->addFilter('HtmlEntities')->setAttrib('class', 'validate[required]')->addValidator($notEmpty->setMessage($this->view->translate("Password is mandatory")))->setRequired(true);
     $notEmpty = clone $notEmpty;
     $emailValidator = new Zend_Validate_EmailAddress();
     $email = $this->adminForm->createElement('text', 'email')->setLabel('Email:')->addFilter('StripTags')->addFilter('StringTrim')->addFilter('HtmlEntities')->setAttrib('class', 'validate[email,required]')->addValidator($notEmpty->setMessage($this->view->translate("Email is mandatory")))->addValidator($emailValidator->setMessage($this->view->translate("Email is invalid")))->setRequired(true);
     $submit = $this->adminForm->createElement('submit', 'save')->setLabel('Save');
     $this->adminForm->addElement($realname)->addElement($username)->addElement($password)->addElement($email)->addElement($submit);
     $dg = $this->adminForm->addDisplayGroup(array('realname', 'username', 'password', 'email', 'save'), 'user');
     if ($this->getRequest()->isPost()) {
         $this->validateAdminUser();
         return;
     }
     $this->view->form = $this->adminForm->render();
 }
Ejemplo n.º 4
0
 private function _configureTheme()
 {
     configureTheme("_admin/" . $this->_conf->general->admin_theme, 'index', '/themes/_admin/' . $this->_conf->general->admin_theme . '/layouts');
 }
Ejemplo n.º 5
0
 public function step2Action()
 {
     $this->reloadConfig();
     configureTheme(APPLICATION_THEME, 'install');
     $session = new Zend_Session_Namespace('Install');
     // Set up Doctrine DB
     require_once APPLICATION_DIRECTORY . '/Joobsbox/Db/Doctrine.php';
     $loader = Zend_Loader_Autoloader::getInstance();
     $loader->pushAutoloader(array('Doctrine', 'autoload'));
     $doctrineConfig = new Zend_Config_Xml(APPLICATION_DIRECTORY . "/config/db.xml", "doctrine");
     $manager = Doctrine_Manager::getInstance();
     $manager->setAttribute(Doctrine::ATTR_TBLNAME_FORMAT, $this->config->db->prefix . '%s');
     $manager->setCollate('utf8_unicode_ci');
     $manager->setCharset('utf8');
     $manager->openConnection($doctrineConfig->connection_string);
     Doctrine::createTablesFromModels($doctrineConfig->models_path);
     $db = Zend_Registry::get("db");
     $db->delete($this->config->db->prefix . "categories", array("Name='Uncategorized'"));
     $db->insert($this->config->db->prefix . "categories", array('ID' => 0, 'Name' => 'Uncategorized', 'Link' => 'Uncategorized', 'OrderIndex' => 100, 'Parent' => 0));
     // Make the form
     $this->adminForm = new Zend_Form();
     $this->adminForm->setAction($this->view->baseUrl . "/install/step2")->setMethod('post')->setLegend('Administrator credentials');
     $notEmpty = new Zend_Validate_NotEmpty();
     $realname = $this->adminForm->createElement('text', 'realname')->setLabel('Your name:')->addFilter('StripTags')->addFilter('StringTrim')->addFilter('HtmlEntities')->setAttrib('class', 'validate[required]')->addValidator($notEmpty->setMessage($this->view->translate("Real name is mandatory")))->setRequired(true);
     $notEmpty = clone $notEmpty;
     $username = $this->adminForm->createElement('text', 'username')->setLabel('Username:'******'StripTags')->addFilter('StringTrim')->addFilter('HtmlEntities')->setAttrib('class', 'validate[required]')->addValidator($notEmpty->setMessage($this->view->translate("Username is mandatory")))->setRequired(true);
     $notEmpty = clone $notEmpty;
     $password = $this->adminForm->createElement('text', 'password')->setLabel('Password:'******'StripTags')->addFilter('StringTrim')->addFilter('HtmlEntities')->setAttrib('class', 'validate[required]')->addValidator($notEmpty->setMessage($this->view->translate("Password is mandatory")))->setRequired(true);
     $notEmpty = clone $notEmpty;
     $emailValidator = new Zend_Validate_EmailAddress();
     $email = $this->adminForm->createElement('text', 'email')->setLabel('Email:')->addFilter('StripTags')->addFilter('StringTrim')->addFilter('HtmlEntities')->setAttrib('class', 'validate[email,required]')->addValidator($notEmpty->setMessage($this->view->translate("Email is mandatory")))->addValidator($emailValidator->setMessage($this->view->translate("Email is invalid")))->setRequired(true);
     $submit = $this->adminForm->createElement('submit', 'Save')->setLabel('Save');
     $this->adminForm->addElement($realname)->addElement($username)->addElement($password)->addElement($email)->addElement($submit);
     $dg = $this->adminForm->addDisplayGroup(array('realname', 'username', 'password', 'email', 'Save'), 'user');
     if ($this->getRequest()->isPost()) {
         $this->validateAdminUser();
         return;
     }
     $this->view->form = $this->adminForm->render();
 }
Ejemplo n.º 6
0
 public function init()
 {
     $url = $_SERVER['REQUEST_URI'];
     if (substr($url, -1) != '/') {
         header("Location: " . $url . '/');
         exit;
     }
     $this->corePluginPath = APPLICATION_DIRECTORY . "/Joobsbox/Plugin";
     $this->corePluginUrl = $this->view->noScriptBaseUrl . "/Joobsbox/Plugin";
     $this->pluginPath = APPLICATION_DIRECTORY . "/plugins";
     $this->pluginUrl = $this->view->noScriptBaseUrl . "/plugins";
     $this->_helper->Event("admin_panel_init");
     $this->_conf = Zend_Registry::get("conf");
     if (file_exists(APPLICATION_DIRECTORY . "/Joobsbox/Version")) {
         $this->view->version = file_get_contents(APPLICATION_DIRECTORY . "/Joobsbox/Version");
     } else {
         $this->view->version = "0.9.20090701";
         @file_put_contents(APPLICATION_DIRECTORY . "/Joobsbox/Version", "0.9.20090701");
     }
     configureTheme("_admin/" . $this->_conf->general->admin_theme, 'index', '/themes/_admin/' . $this->_conf->general->admin_theme . '/layouts');
     // Get plugin order from configuration file
     if (isset($this->_conf->admin->menu)) {
         $this->corePlugins = explode(",", $this->_conf->admin->menu);
     }
     // Initialize plugins
     $this->plugins = array();
     $this->menuPlugins = array();
     $this->dashboardCandidates = array();
     // Search for them
     foreach (new DirectoryIterator($this->corePluginPath) as $plugin) {
         $name = $plugin->getFilename();
         if ($plugin->isDir() && $name[0] != '.' && $name[0] != '_') {
             require_once $this->corePluginPath . "/{$name}/{$name}.php";
             // Analyze prerequisites
             $class = new ReflectionClass(ucfirst($name));
             if (file_exists($this->corePluginPath . '/' . $name . '/config.xml')) {
                 $this->plugins[$name] = new Zend_Config_Xml($this->corePluginPath . '/' . $name . '/config.xml', null, array("allowModifications" => true));
                 $this->plugins[$name]->paths = array();
                 $this->plugins[$name]->paths->dirPath = $this->corePluginPath;
                 $this->plugins[$name]->paths->urlPath = $this->corePluginUrl;
                 $this->menuPlugins[$name] = $this->plugins[$name];
                 $this->pluginPaths[$name] = $this->corePluginPath . '/' . $name;
             }
             if ($class->hasMethod('dashboard')) {
                 $this->dashboardCandidates[$name] = 1;
             }
         }
     }
     // Search for the other plugins - dashboard purposes
     foreach (new DirectoryIterator($this->pluginPath) as $plugin) {
         $name = $plugin->getFilename();
         if ($plugin->isDir() && $name[0] != '.' && $name[0] != '_') {
             require_once $this->pluginPath . "/{$name}/{$name}.php";
             // Analyze prerequisites
             $class = new ReflectionClass(ucfirst($name));
             if (file_exists($this->pluginPath . '/' . $name . '/config.xml')) {
                 $this->plugins[$name] = new Zend_Config_Xml($this->pluginPath . '/' . $name . '/config.xml', null, array("allowModifications" => true));
                 $this->plugins[$name]->paths = array();
                 $this->plugins[$name]->paths->dirPath = $this->pluginPath;
                 $this->plugins[$name]->paths->urlPath = $this->pluginUrl;
                 $this->pluginPaths[$name] = $this->pluginPath . '/' . $name;
             }
             if ($class->hasMethod('dashboard')) {
                 $this->dashboardCandidates[$name] = 1;
             }
         }
     }
     if (isset($this->corePlugins) && count(array_diff($this->corePlugins, array_keys($this->plugins)))) {
         $this->corePlugins = array_keys($this->plugins);
         // Write it to config so that we don't miss it furtherwise
         $tmp = new Zend_Config_Xml("config/config.xml", null, array('allowModifications' => true));
         $tmp->admin->menu = implode(",", $this->corePlugins);
         $writer = new Zend_Config_Writer_Xml(array('config' => $tmp, 'filename' => 'config/config.xml'));
         $writer->write();
         unset($tmp, $writer);
     }
     uksort($this->menuPlugins, array($this, "sortFunction"));
     $this->view->corePlugins = $this->corePlugins;
     $this->view->corePluginPath = $this->corePluginPath;
     $this->view->pluginPath = $this->pluginPath;
     $this->view->plugins = $this->menuPlugins;
     $this->view->pluginsThemePath = str_replace("index.php", "", $this->view->baseUrl);
     $this->view->locale = Zend_Registry::get("Zend_Locale");
     $session = new Zend_Session_Namespace("AdminPanel");
     $this->alerts = array_merge($this->alerts, $this->_helper->FlashMessenger->getMessages());
     $this->alerts = array_merge($this->alerts, array_unique($session->alerts));
     unset($session->alerts);
     /* Load stuff */
     $this->view->css->load("reset.css", "global.css");
     $this->view->headScript()->prependScript($this->view->translateHash . 'var baseUrl = "' . $this->view->baseUrl . '";' . ' var href = "' . $_SERVER['REQUEST_URI'] . '";', 'text/javascript', array('charset' => 'UTF-8'));
     $this->view->js->load('functions.js');
     $this->view->asset->load("jquery", "jquery-pngfix");
     $this->view->js->load(array('global.js', 100));
 }