function admin_setup()
 {
     if ($this->layout) {
         $this->layout = $this->load->layout('admin');
     }
     $default_utility = '/' . DEFAULT_MODULE . '/admin/' . DEFAULT_MODULE . 'admin';
     if (!file_exists(APPD_APPLICATION . '/' . DEFAULT_MODULE . '/admin/' . DEFAULT_MODULE . 'admin.utility.php')) {
         $default_utility = '/admin/admin/adminadmin';
     }
     $util = $this->load->utility($default_utility);
     $path = $util ? DEFAULT_MODULE . '/' . DEFAULT_MODULE : 'admin/index';
     $default_config = array('roles' => array('admin' => array('home' => $path, 'modules' => '*')), 'time_limit' => 500, 'memory_limit' => '128M');
     $this->config = array_merge($default_config, $this->config);
     $roles = array_keys($this->config['roles']);
     $this->plugin->Auth->addArea('admin-area', $roles);
     foreach ($roles as $role) {
         $this->plugin->Auth->addRole($role, array('member-area', 'admin-area', 'open-area'));
     }
     $this->plugin->Auth->authorize('admin-area', array('admin', 'node', 'node_process', 'error'), array(&$this, '_goLogin'));
     if (isset($this->config['language']) && $this->config['language'] != Lang::getCurrent()) {
         $this->helper->redirect->to(UrlHelper::current($this->config['language']));
     }
     if (!ini_get('safe_mode') && is_callable('set_time_limit') && is_callable('ini_set')) {
         @set_time_limit($this->config['time_limit']);
         @ini_set("memory_limit", $this->config['memory_limit']);
     }
 }
示例#2
0
 function langImg($path, $alt = '', $attributes = array())
 {
     $parts = explode('/', $path, 2);
     if (isset($parts[1])) {
         $parts[2] = $parts[1];
         $parts[1] = Lang::getCurrent();
     }
     $path = implode('/', $parts);
     return $this->img($path, $alt, $attributes);
 }
 protected function preprocess($uri)
 {
     $parts = explode('/', $uri);
     setlocale(LC_ALL, Lang::getCurrent());
     /**
      * Removes any trailing slash as efficiently as I could do it!
      */
     if (end($parts) === '') {
         array_pop($parts);
     }
     return $parts;
 }
 function page()
 {
     $this->helper->filter->defaults($this->args, array(0 => '', 1 => '', 2 => ''));
     $lang_id = Lang::getCurrent();
     $page = $this->db->Cms->getPage($this->args, $lang_id);
     if (!$page) {
         $this->helper->redirect->to($this->plugin->Error->get404());
     }
     $view = $this->view = $this->_call('/' . $page['template'], array('page_id' => $page['page_id']));
     if (!$view) {
         $this->helper->redirect->to($this->plugin->Error->get404());
     }
     $this->layout->setTitle($page['meta_title']);
     $this->layout->setDescription($page['description']);
     $this->layout->setKeywords($page['keywords']);
     $this->layout->view->set('page', $page);
     $this->view->set('page', $page);
 }
 function page_metadata()
 {
     $nav_item_id = $this->node->arg('nav_item_id');
     $nav_info = $this->db->from('cms_nav_item')->where('nav_item_id', $nav_item_id)->join('cms_nav_item_name', 'nav_item_id')->where('language_id', Lang::getCurrent())->fetchRow();
     $form = $this->components->add('form', array('title' => $nav_info['name'] . ' - Metadata', 'back' => true));
     $page = $form->addTable('cms_page', array('template' => array('type' => 'hidden')));
     $values = $this->db->from('cms_page')->where('page_id', $this->node->arg('page_id'))->fetchRow();
     $form->setValues($page, $values);
     $langs = $this->db->from('cms_language')->fetchAllRows();
     $texts = array();
     foreach ($langs as $lang) {
         $nav_item = $form->addTable('cms_nav_item_name', array('name' => array('validator' => array('required' => true), 'label' => 'Menu Entry'), 'language_id' => array('value' => $lang['language_id'])));
         $values = $this->db->from('cms_nav_item_name')->where('nav_item_id', $nav_item_id)->where('language_id', $lang['language_id'])->fetchRow();
         $form->setValues($nav_item, $values);
         $page_meta = $form->addTable('cms_page_meta', array('url_entry' => array('validator' => $this->valid->get('url_identifier', 'required')), 'language_id' => array('value' => $lang['language_id'])));
         $page_meta->page_id->setReference($page->page_id);
         $text = $this->db->from('cms_page_meta')->where('page_id', $this->node->arg('page_id'))->where('language_id', $lang['language_id'])->fetchRow();
         $form->setValues($page_meta, $text);
         $texts[$lang['language_id']] = array($nav_item, $page_meta);
     }
     $fields = array();
     if (count($langs) > 1) {
         /**
          * Add Language Tabs
          */
         $tabs = $form->getFormObject()->add('/admin/formtabs', 'tabs');
         $lang_tabs = array();
         foreach ($langs as $lang) {
             $lang_tabs[] = array($lang['name'], 'lang_' . $lang['language_id']);
         }
         $tabs->addTabs($lang_tabs);
         $fields = array('tabs');
     }
     foreach ($langs as $lang) {
         $fields['tab_fieldset lang_' . $lang['language_id']] = array($texts[$lang['language_id']][0]->name, $texts[$lang['language_id']][1]->url_entry, $texts[$lang['language_id']][1]->title, $texts[$lang['language_id']][1]->meta_title, $texts[$lang['language_id']][1]->description, $texts[$lang['language_id']][1]->keywords);
     }
     $form->fieldset($fields, array('class' => 'tabs'));
 }
 static function getDefaultErrorMessages()
 {
     $load = new Loader(new Context('lang', 'phaxsi'));
     $lang = $load->lang();
     if ($lang) {
         return $lang->default_errors;
     }
     $current = Lang::getCurrent();
     if (isset(AppConfig::$generic_error_message[$current])) {
         return array(AppConfig::$generic_error_message[$current]);
     }
     return array(AppConfig::$generic_error_message[AppConfig::DEFAULT_LANGUAGE]);
 }
示例#7
0
 final function lang($path = null)
 {
     /*
      * Avoid looking again for a class that was not found before
      */
     static $failed = array();
     if (!$path) {
         $path = $this->context->getPath();
     }
     if (isset($failed[$path])) {
         return null;
     }
     $current_lang = Lang::getCurrent();
     $context = $this->context->deriveContext('lang', $path);
     $class_name = self::includeApplicationClass($context, $current_lang);
     if ($class_name) {
         return new $class_name($context, $this);
     }
     /**
      * Load default language file if the one for the current language is not found
      */
     if ($current_lang != AppConfig::DEFAULT_LANGUAGE) {
         $class_name = self::includeApplicationClass($context, AppConfig::DEFAULT_LANGUAGE);
         if ($class_name) {
             return new $class_name($context, $this);
         }
     }
     $failed[$path] = 1;
     return null;
 }
示例#8
0
 private function _generateKey($params)
 {
     $type_info = PhaxsiConfig::$type_info[$this->context->getType()];
     $file_root = $this->context->getAction() . '.' . $this->context->getType();
     $DS = $type_info['basedir'] == '' ? "" : DS;
     $params_str = "";
     if ($params) {
         foreach ($params as $key => $value) {
             $params_str .= preg_replace('/[^a-z0-9_-]/', '_', '_' . $key . '-' . $value);
         }
     } else {
         $params_str = $file_root;
     }
     return DS . Lang::getCurrent() . DS . $this->context->getModule() . DS . $type_info['basedir'] . $DS . $file_root . DS . $params_str;
 }
示例#9
0
 protected function getHeadHtml()
 {
     $html = new HtmlHelper($this->context);
     $output = '';
     foreach ($this->metas as $meta) {
         if ($meta['name']) {
             $output .= "<meta name=\"{$meta['name']}\" content=\"" . HtmlHelper::escape($meta['content']) . "\" />\r\n";
         } elseif ($meta['http-equiv']) {
             $output .= "<meta http-equiv=\"{$meta['http-equiv']}\" content=\"" . HtmlHelper::escape($meta['content']) . "\" />\r\n";
         }
     }
     $output .= "<title>" . HtmlHelper::escape($this->title) . "</title>\r\n";
     $output .= '<base href="' . UrlHelper::get('/') . '"/>' . "\r\n";
     if ($this->favico) {
         $output .= '<link rel="icon" type="' . $this->favico[1] . "\" href=\"" . UrlHelper::resource($this->favico[0]) . "\">\r\n";
     }
     if ($this->description) {
         $output .= '<meta name="description" content="' . HtmlHelper::escape($this->description) . "\" />\r\n";
     }
     if ($this->keywords) {
         $output .= '<meta name="keywords" content="' . HtmlHelper::escape($this->keywords) . "\" />\r\n";
     }
     foreach ($this->feeds as $feed) {
         $output .= '<link rel="alternate" type="application/rss+xml" title="RSS" href="' . UrlHelper::get($feed) . "\" />\r\n";
     }
     foreach ($this->styles as $style) {
         $output .= $html->css($style[0], $style[1]) . "\r\n";
     }
     if ($this->js_library) {
         $output .= "<script type=\"text/javascript\" src=\"{$this->js_library}\"></script>\r\n";
         $output .= $html->javascript('/' . APPU_PHAXSI . '/' . 'phaxsi-' . PhaxsiConfig::FRAMEWORK_VERSION . (AppConfig::DEBUG_MODE ? '' : '.min') . '.js') . "\r\n";
         $output .= HtmlHelper::inlineJavascript("Phaxsi.path = {" . "base: '" . UrlHelper::get('') . "'," . "local: '" . UrlHelper::localized('/') . "'," . "'public': '" . APPU_PUBLIC . "'," . "lang: '" . Lang::getCurrent() . "'}");
     }
     foreach ($this->scripts as $script) {
         $output .= $html->javascript($script) . "\r\n";
     }
     $this->styles = $this->scripts = array();
     return $output;
 }
 private function preprocess($uri)
 {
     /**
      * Removes BASE_URL from $uri, including the initial '/'.
      */
     $uri = substr_replace(strtolower($uri), '', 0, strlen(AppConfig::BASE_URL));
     $parts = explode('/', $uri);
     /**
      * Detects if there is a language specified in the url,
      * and if so, sets the context language. $parts[0] always exist
      * given the returning values of explode function.
      */
     if (@in_array($parts[0], AppConfig::$available_languages, true) && ($parts[0] != AppConfig::DEFAULT_LANGUAGE || AppConfig::$language_redirect)) {
         Lang::setCurrent(array_shift($parts));
     }
     setlocale(LC_ALL, Lang::getCurrent());
     /**
      * Removes any trailing slash as efficiently as I could do it!
      */
     if (end($parts) === '') {
         array_pop($parts);
     }
     return implode('/', $parts);
 }
示例#11
0
<?php

echo $this->load->block('message', array('messages' => $messages, 'component' => $_component));
?>

<div class="form">

	<?php 
echo $form->open();
?>

		<div class="input-submit">

			<button type="submit" id="button_sub"><?php 
echo $html->img('/admin/components/images/save_' . Lang::getCurrent() . '.png');
?>
</button>

			<?php 
if ($back) {
    ?>
				<script type="text/javascript">
					$(document).ready(function(){
						var form = "<?php 
    echo $form->getId();
    ?>
";
						jQuery('#'+form).submit(function(){
							var action = $('#'+form).attr('action');
							action += 'back=0';
							$('#'+form).attr('action', action);
示例#12
0
 static function current($lang = '', $include_host = true)
 {
     if ($include_host) {
         $host = "http://" . AppConfig::HTTP_HOST . AppConfig::BASE_URL;
     } else {
         $host = '/';
     }
     $uri = preg_replace('/^' . str_replace('/', '\\/', AppConfig::BASE_URL) . '/', '', $_SERVER['REQUEST_URI']);
     if (!$lang) {
         return $host . $uri;
     } else {
         if ($lang == AppConfig::DEFAULT_LANGUAGE && !AppConfig::$language_redirect) {
             if (Lang::getCurrent() != $lang) {
                 $uri = preg_replace('/^' . Lang::getCurrent() . '\\//', '', $uri);
                 return $host . $uri;
             } else {
                 return $host . $uri;
             }
         } else {
             if (Lang::getCurrent() != $lang || AppConfig::$language_redirect) {
                 $uri = preg_replace('/^' . Lang::getCurrent() . '\\//', '', $uri);
                 return $host . $lang . '/' . $uri;
             } else {
                 return $host . $uri;
             }
         }
     }
 }
示例#13
0
	<?php 
echo $form->open();
?>

		<div class="input-submit">
			<button type="submit" ><?php 
echo $html->img('save_' . Lang::getCurrent() . '.png');
?>
</button>

			<?php 
if ($back) {
    ?>
				<button type="submit" id="button_sub" ><?php 
    echo $html->img('save_and_back_' . Lang::getCurrent() . '.png');
    ?>
</button>
				<script type="text/javascript">
					var form = "<?php 
    echo $form->getId();
    ?>
";
					jQuery('#button_sub').mousedown(function(){
						var action = $('#'+form).attr('action');
						action += 'back=0';
						$('#'+form).attr('action', action);
					});
				</script>
			<?php 
}