Ok, The site is working fine but I've installed a new module and I'm receiving this error when trying to access the admin login now. I cannot login to the admin. I am a beginner level coder.
Notice: Undefined property: Loader::$load in /hermes/walnaweb03a/b905/moo.mattestincom/peddlerplace/osclass/shop/vqmod/vqcache/vq2-admin_view_template_common_header.tpl on line 96
Fatal error: Call to a member function model() on a non-object in /hermes/walnaweb03a/b905/moo.mattestincom/peddlerplace/osclass/shop/vqmod/vqcache/vq2-admin_view_template_common_header.tpl on line 96
I was able to find this file (admin_view_template_common_header.tpl) in my FTP. I opened it in Sublime Text Editor and line 96 shows this code
<?php $this->load->model('multiseller/upgrade'); ?>
Below is the full code of the entire admin_view_template_common_header.tpl file
<!DOCTYPE html>
<html dir="<?php echo $direction; ?>" lang="<?php echo $lang; ?>">
<head>
<meta charset="UTF-8" />
<title><?php echo $title; ?></title>
<base href="<?php echo $base; ?>" />
<?php if ($description) { ?>
<meta name="description" content="<?php echo $description; ?>" />
<?php } ?>
<?php if ($keywords) { ?>
<meta name="keywords" content="<?php echo $keywords; ?>" />
<?php } ?>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<script type="text/javascript" src="view/javascript/jquery/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="view/javascript/bootstrap/js/bootstrap.min.js"></script>
<link href="view/stylesheet/bootstrap.css" type="text/css" rel="stylesheet" />
<link href="view/javascript/font-awesome/css/font-awesome.min.css" type="text/css" rel="stylesheet" />
<link href="view/javascript/summernote/summernote.css" rel="stylesheet" />
<script type="text/javascript" src="view/javascript/summernote/summernote.js"></script>
<script src="view/javascript/jquery/datetimepicker/moment.js" type="text/javascript"></script>
<script src="view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<link href="view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css" type="text/css" rel="stylesheet" media="screen" />
<link type="text/css" href="view/stylesheet/stylesheet.css" rel="stylesheet" media="screen" />
<?php foreach ($styles as $style) { ?>
<link type="text/css" href="<?php echo $style['href']; ?>" rel="<?php echo $style['rel']; ?>" media="<?php echo $style['media']; ?>" />
<?php } ?>
<?php foreach ($links as $link) { ?>
<link href="<?php echo $link['href']; ?>" rel="<?php echo $link['rel']; ?>" />
<?php } ?>
<script src="view/javascript/common.js" type="text/javascript"></script>
<?php global $config; $this->config = $config; ?>
<script type="text/javascript"> if (!window.console) console = {log: function() {}}; var msGlobals = { config_limit_admin: '<?php echo $this->config->get('config_limit_admin'); ?>', config_language: <?php echo $dt_language; ?> }; </script>
<?php foreach ($scripts as $script) { ?>
<script type="text/javascript" src="<?php echo $script; ?>"></script>
<?php } ?>
</head>
<body>
<div id="container">
<header id="header" class="navbar navbar-static-top">
<div class="navbar-header">
<?php if ($logged) { ?>
<a type="button" id="button-menu" class="pull-left"><i class="fa fa-indent fa-lg"></i></a>
<?php } ?>
<img src="view/image/logo.png" alt="<?php echo $heading_title; ?>" title="<?php echo $heading_title; ?>" /></div>
<?php if ($logged) { ?>
<ul class="nav pull-right">
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown"><span class="label label-danger pull-left"><?php echo $alerts; ?></span> <i class="fa fa-bell fa-lg"></i></a>
<ul class="dropdown-menu dropdown-menu-right alerts-dropdown">
<li class="dropdown-header"><?php echo $text_order; ?></li>
<li><span class="label label-warning pull-right"><?php echo $processing_status_total; ?></span><?php echo $text_processing_status; ?></li>
<li><span class="label label-success pull-right"><?php echo $complete_status_total; ?></span><?php echo $text_complete_status; ?></li>
<li><span class="label label-danger pull-right"><?php echo $return_total; ?></span><?php echo $text_return; ?></li>
<li class="divider"></li>
<li class="dropdown-header"><?php echo $text_customer; ?></li>
<li><span class="label label-success pull-right"><?php echo $online_total; ?></span><?php echo $text_online; ?></li>
<li><span class="label label-danger pull-right"><?php echo $customer_total; ?></span><?php echo $text_approval; ?></li>
<li class="divider"></li>
<li class="dropdown-header"><?php echo $text_product; ?></li>
<li><span class="label label-danger pull-right"><?php echo $product_total; ?></span><?php echo $text_stock; ?></li>
<li><span class="label label-danger pull-right"><?php echo $review_total; ?></span><?php echo $text_review; ?></li>
<li class="divider"></li>
<li class="dropdown-header"><?php echo $text_affiliate; ?></li>
<li><span class="label label-danger pull-right"><?php echo $affiliate_total; ?></span><?php echo $text_approval; ?></li>
</ul>
</li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-life-ring fa-lg"></i></a>
<ul class="dropdown-menu dropdown-menu-right">
<li class="dropdown-header"><?php echo $text_store; ?> <i class="fa fa-shopping-cart"></i></li>
<?php foreach ($stores as $store) { ?>
<li><?php echo $store['name']; ?></li>
<?php } ?>
<li class="divider"></li>
<li class="dropdown-header"><?php echo $text_help; ?> <i class="fa fa-life-ring"></i></li>
<li><?php echo $text_homepage; ?></li>
<li><?php echo $text_documentation; ?></li>
<li><?php echo $text_support; ?></li>
</ul>
</li>
<li><span class="hidden-xs hidden-sm hidden-md"><?php echo $text_logout; ?></span> <i class="fa fa-sign-out fa-lg"></i></li>
</ul>
<?php } ?>
</header>
<?php if (!class_exists('ControllerMultisellerBase')) { ?>
<div class="alert alert-warning" style="margin: 10px auto; width: 90%;"><i class="fa fa-exclamation-circle"></i> MultiMerch Core Class not found. Before proceeding with the installation, please make sure that:
<ul>
<li>You're <a target="_blank" href="http://multimerch.com/docs/installation/">following the MultiMerch installation guide</a> and all MultiMerch files have been uploaded correctly.</li>
<li>vQmod is <a target="_blank" href="https://github.com/vqmod/vqmod/wiki/Installing-vQmod-on-OpenCart">installed and configured correctly</a> and vQmod installation script at <a target="_blank" href="<?php echo HTTP_CATALOG; ?>vqmod/install/"><?php echo HTTP_CATALOG; ?>vqmod/install/</a> has been run.</li>
<li>Your server has write permissions on vQmod folders.</li>
</ul>
</div>
<?php } ?>
<?php $this->load->model('multiseller/upgrade'); ?>
<?php if ($this->MsLoader->MsHelper->isInstalled() && !$this->model_multiseller_upgrade->isDbLatest()) { ?>
<div class="alert-warning" style="text-align:center; margin: 10px"><?php echo sprintf($this->language->get('ms_db_upgrade'), $this->url->link('module/multiseller/upgradeDb', 'token=' . $this->session->data['token'], 'SSL')); ?></div>
<?php } ?>
<?php if (isset($this->session->data['ms_db_latest'])) { ?>
<div class="alert-success" style="text-align:center; margin: 10px"><?php echo $this->session->data['ms_db_latest']; ?></div>
<?php unset($this->session->data['ms_db_latest']); ?>
<?php } ?>
Error: undefined property $load
Take me to what I believe may be very similar.
If this is the case, How do I find
function __construct()
{
parent::__construct();
/*Additional code which you want to run automatically in every function call */
}
********UPDATE********
After following the suggestion and changing the code, this error now appears
Warning: Missing argument 1 for Loader::__construct(), called in /hermes/walnaweb03a/b905/moo.mattestincom/peddlerplace/osclass/shop/vqmod/vqcache/vq2-admin_view_template_common_header.tpl on line 96 and defined in /hermes/walnaweb03a/b905/moo.mattestincom/peddlerplace/osclass/shop/vqmod/vqcache/vq2-system_engine_loader.php on line 14Notice: Undefined variable: registry in /hermes/walnaweb03a/b905/moo.mattestincom/peddlerplace/osclass/shop/vqmod/vqcache/vq2-system_engine_loader.php on line 15Notice: Undefined variable: registry in /hermes/walnaweb03a/b905/moo.mattestincom/peddlerplace/osclass/shop/vqmod/vqcache/vq2-system_engine_loader.php on line 18 Fatal error: Call to a member function set() on a non-object in /hermes/walnaweb03a/b905/moo.mattestincom/peddlerplace/osclass/shop/vqmod/vqcache/vq2-system_engine_loader.php on line 18
private $registry;
public function __construct($registry) {
$this->registry = $registry;
require_once(VQMod::modCheck(VQMod::modCheck(DIR_SYSTEM . 'library/msloader.php')));
$registry->set('MsLoader', new MsLoader($registry));
}
public function controller($route, $data = array()) {
// $this->event->trigger('pre.controller.' . $route, $data);
$parts = explode('/', str_replace('../', '', (string)$route));
// Break apart the route
while ($parts) {
$file = DIR_APPLICATION . 'controller/' . implode('/', $parts) . '.php';
$class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '', implode('/', $parts));
if (is_file($file)) {
include_once(VQMod::modCheck($file));
break;
} else {
$method = array_pop($parts);
}
}
$controller = new $class($this->registry);
if (!isset($method)) {
$method = 'index';
}
// Stop any magical methods being called
if (substr($method, 0, 2) == '__') {
return false;
}
$output = '';
if (is_callable(array($controller, $method))) {
$output = call_user_func(array($controller, $method), $data);
}
// $this->event->trigger('post.controller.' . $route, $output);
return $output;
}
public function model($model, $data = array()) {
// $this->event->trigger('pre.model.' . str_replace('/', '.', (string)$model), $data);
$model = str_replace('../', '', (string)$model);
$file = DIR_APPLICATION . 'model/' . $model . '.php';
$class = 'Model' . preg_replace('/[^a-zA-Z0-9]/', '', $model);
if (file_exists($file)) {
include_once(VQMod::modCheck($file));
$this->registry->set('model_' . str_replace('/', '_', $model), new $class($this->registry));
} else {
trigger_error('Error: Could not load model ' . $file . '!');
exit();
}
// $this->event->trigger('post.model.' . str_replace('/', '.', (string)$model), $output);
}
public function view($template, $data = array()) {
// $this->event->trigger('pre.view.' . str_replace('/', '.', $template), $data);
$file = DIR_TEMPLATE . $template;
if (file_exists($file)) {
extract($data);
ob_start();
require(VQMod::modCheck($file));
$output = ob_get_contents();
ob_end_clean();
} else {
trigger_error('Error: Could not load template ' . $file . '!');
exit();
}
// $this->event->trigger('post.view.' . str_replace('/', '.', $template), $output);
return $output;
}
public function helper($helper) {
$file = DIR_SYSTEM . 'helper/' . str_replace('../', '', (string)$helper) . '.php';
if (file_exists($file)) {
include_once(VQMod::modCheck($file));
} else {
trigger_error('Error: Could not load helper ' . $file . '!');
exit();
}
}
public function config($config) {
$this->registry->get('config')->load($config);
}
public function language($language) {
return $this->registry->get('language')->load($language);
}
}
In new version of OC we can't load any access the library on template files, to do it we have to load that first & then we can use it.
Please try this code on line no 96
$load = new Loader();
$load->model('multiseller/upgrade');
Instead of $this->load->model('multiseller/upgrade');
I'm probably a bit late to answer this, but this is actually caused by a combined setup of MultiMerch and Journal with the older version of our MultiMerch-Journal integration pack.
In case anyone else is having the same issue, please update your Journal compatibility pack to the latest version available in our GitHub repo.
Related
My company is working on a CRM with the Wordpress plugin CQPIM.
There are two issues with it, but I'll just address one, for now.
The plugin functions off of User Roles, and will show ALL the active projects for anyone with the capability: cqpim_view_all_projects.
We need to rewrite the following snippet so that the dashboard only shows the projects assigned to the current user.
original code: there are no hooks to filters to modify
if(current_user_can('cqpim_view_all_projects')) {
$index++; ?>
<li>
<script>
jQuery(document).ready(function() {
jQuery("#progressbar-<?php echo $project->ID; ?>").progressbar({
value: <?php echo number_format((float)$pc_complete, 2, '.', ''); ?>
});
});
</script>
<div class="title">
<?php if(!empty($project->post_title)) { echo $project->post_title; } else { _e('Untitled', 'cqpim'); } ?>
<?php echo $project_status; ?>
</div>
<div class="progress">
<div id="progressbar-<?php echo $project->ID; ?>"></div>
</div>
<ul class="project_stats">
<li><span class="project_stat_head"><?php _e('Open Tasks' , 'cqpim') ?></span><span class="project_stat"><?php echo $task_count; ?></span></li>
<li><span class="project_stat_head"><?php _e('Complete' , 'cqpim') ?></span><span class="project_stat"><?php echo number_format((float)$pc_complete, 2, '.', ''); ?>%</span></li>
<li><span class="project_stat_head"><?php _e('Deadline' , 'cqpim') ?></span><span class="project_stat"><?php echo $finish_date; ?></span></li>
</ul>
</li>
<?php
} else {
$access = false;
$project_contributors = get_post_meta($project->ID, 'project_contributors', true);
if(empty($project_contributors)) {
$project_contributors = array();
}
foreach($project_contributors as $contributor) {
if(!empty($contributor['team_id']) && $assigned == $contributor['team_id']) {
$access = true;
}
}
if($access == true) {
$index++; ?>
<li>
<script>
jQuery(document).ready(function() {
jQuery("#progressbar-<?php echo $project->ID; ?>").progressbar({
value: <?php echo number_format((float)$pc_complete, 2, '.', ''); ?>
});
});
</script>
<div class="title">
<?php if(!empty($project->post_title)) { echo $project->post_title; } else { _e('Untitled', 'cqpim'); } ?>
<?php echo $project_status; ?>
</div>
<div class="progress">
<div id="progressbar-<?php echo $project->ID; ?>"></div>
</div>
<ul class="project_stats">
<li><span class="project_stat_head"><?php _e('Open Tasks', 'cqpim'); ?></span><span class="project_stat"><?php echo $task_count; ?></span></li>
<li><span class="project_stat_head"><?php _e('Complete' , 'cqpim') ?></span><span class="project_stat"><?php echo number_format((float)$pc_complete, 2, '.', ''); ?>%</span></li>
<li><span class="project_stat_head"><?php _e('Deadline' , 'cqpim') ?></span><span class="project_stat"><?php echo $finish_date; ?></span></li>
</ul>
</li>
<?php
}
}
My modified code: it works when in the plugin root, but I would like to update this plugin at some point without losing all my files, so need a way to overwrite the original IF statement
if(current_user_can('cqpim_view_all_projects')) {
$index++;
$access = false;
$project_contributors = get_post_meta($project->ID, 'project_contributors', true);
if(empty($project_contributors)) {
$project_contributors = array();
}
foreach($project_contributors as $contributor) {
if(!empty($contributor['team_id']) && $assigned == $contributor['team_id']) {
$access = true;
}
}
if($access == true) {
$index++; ?>
<li>
<script>
jQuery(document).ready(function() {
jQuery("#progressbar-<?php echo $project->ID; ?>").progressbar({
value: <?php echo number_format((float)$pc_complete, 2, '.', ''); ?>
});
});
</script>
<div class="title">
<?php if(!empty($project->post_title)) { echo $project->post_title; } else { _e('Untitled', 'cqpim'); } ?>
<?php echo $project_status; ?>
</div>
<div class="progress">
<div id="progressbar-<?php echo $project->ID; ?>"></div>
</div>
<ul class="project_stats">
<li><span class="project_stat_head"><?php _e('Open Tasks', 'cqpim'); ?></span><span class="project_stat"><?php echo $task_count; ?></span></li>
<li><span class="project_stat_head"><?php _e('Complete' , 'cqpim') ?></span><span class="project_stat"><?php echo number_format((float)$pc_complete, 2, '.', ''); ?>%</span></li>
<li><span class="project_stat_head"><?php _e('Deadline' , 'cqpim') ?></span><span class="project_stat"><?php echo $finish_date; ?></span></li>
</ul>
</li>
<?php
}
}
If hooks or actions are not available for this plugin, check if the plugin makes use of the function get_template_part/locate_template or something like it. An example is woocommerce, which uses both actions/filters and locate_template so you can either hook into it or overwrite the templates in the theme folder.
Have you tried asking the developer? The plugin is paid, so it would make sense you have some kind of support there. Ask them to include hooks or the ability to overrule templates in your own theme.
I am working on an e-commerece website.I am using sessions as part of my cart system. On the main categories/shop page, the site should load all the items in a category unless it is already in their cart. If the cart is not even set/is empty, it automatically should load all items.
The problem is that, even when I add an item to the cart, it still displays it. I figured out, for some reason, it is not recognizing $_SESSION['cart'] as being set. This is particularly odd because the header, which makes use of a custom cart class that uses $_SESSION['cart'], works as it should (it displays the correct number of items.
What might the issue be?
shop.php
<?php
include("header.php");
$catID = $_GET['cat'];
$db = new pdoAccess("localhost","root","");
$items = $db->getItemsByCategory($catID, "stock");
$category = $db->getCategoryName($catID, "categories");
?>
<div id='mainContent'>
<div class='row'>
<h2 class="categoryHeader"> <?php echo $category;?></h2>
</div>
<?php
foreach($items as $item) {
if(!isset($_SESSSION['cart'])) {
echo "<h2>Cart Not Set!</h2><div class='col-sm-4 well'><div class='row'><img class='img-responsive' src='img/items/$item->image'></div><div class='row itemTitle'><a href='item.php?id=$item->id'>$item->name</a></div><div class='row price'>Price: $item->price</div><div class='row condition'>Condition: $item->condition</div> </div>";
} else {
if(array_search($item->id, $_SESSSION['cart']) == false) { // the item is not in the cart
echo "<h2>" . $_SESSSION['cart'] . "</h2>";
echo "<div class='col-sm-4 well'><div class='row'><img class='img-responsive' src='img/items/$item->image'></div><div class='row itemTitle'><a href='item.php?id=$item->id'>$item->name</a></div><div class='row price'>Price: $item->price</div><div class='row condition'>Condition: $item->condition</div> </div>";
}
}
}
?>
</div>
<?php
include("footer.php");
?>
addCart.php
<?php
include("header.php");
$itemID = $_GET['itemID'];
$catID = $_GET['catID'];
if(isset($_SESSION['cart'])) {
array_push($_SESSION['cart'], $itemID);
} else {
$_SESSION['cart'] = array($itemID);
}
?>
Continue Shopping?
Checkout
item.php
<?php
include("header.php");
$itemID = $_GET['id'];
$db = new pdoAccess("localhost","root","");
$item = $db->getItemDetails($itemID, "stock");
$category = $db->getCategoryName($item->category, "categories");
?>
<div id='mainContent'>
<div class='row'>
<h2 class="itemHeader"> <?php echo $item->name; ?> </h2>
</div>
<div class="row">
<div class='col-md-6'>
<img class='img-responsive' src="img/items/<?php echo $item->image;?>">
</div>
<div class='well col-md-6'><ul><li>Platform: <?php echo $category; ?> </li>
<li>Condition: <?php echo $item->condition; ?></li>
<li>Price: <?php echo $item->price; ?></li>
<//ul>
</div>
</div>
<div class="row">
<div class="col-md-8">
<p><?php echo $item->description; ?></p>
</div>
<div class="col-md-4">
<form action="addCart.php" method='get'>
<input type='hidden' name='itemID' value="<?php echo $item->id;?>" />
<input type='hidden' name='catID' value="<?php echo $category;?>" />
<input type='submit' class="addToCart" value="Add to Cart">
</form>
</div>
</div>
<?php
include("footer.php");
?>
header.php
<?php
session_start();
include("pdo.php");
$cart = new cart();
$itemCount = $cart->getItemCount();
?>
<!doctype html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="scripts/main.js" /></script>
<script src="http://code.jquery.com/jquery-1.12.3.min.js" integrity="sha256-aaODHAgvwQW1bFOGXMeX+pC4PZIPsvn2h1sArYOhgXQ=" crossorigin="anonymous"></script>
<script src="scripts/bootstrap.js" /></script>
<link href="styles/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="styles/base.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<!-- Begin Header -->
<header>
<nav class='navbar navbar-inverse'>
<div class='navbar-header'>
<button class='navbar-toggle' data-toggle='collapse' data-target='headerNav'>
<span class='glyphicon glyphicon-plus-sign' />
</button>
<a class='navbar-brand' href='index.php'><img class='img-responsive' src='logo.png' /></a>
</div>
<div class='collapse navbar-collapse' id='headerNav'>
<ul class='nav navbar-nav'>
<li class='dropdown'>
<a class='dropdown-toggle' data-toggle="dropdown" href="#">Console<span class='glyphicon glyphicon-plus'></span></a>
<ul class='dropdown-menu'>
<li>Playstation</li>
<li>Wii</li>
<li>Gamecube</li>
<li>N64</li>
<li>Other</li>
</ul>
</li>
<li class='dropdown'>
<a class='dropdown-toggle' data-toggle="dropdown" href="#">Portable<span class='glyphicon glyphicon-plus'></span></a>
<ul class='dropdown-menu'>
<li>Nintendo DS</li>
<li>GB/GBC/GBA</li>
<li>Other</li>
</ul>
</li>
<li>Videos</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Cart (<?php if($itemCount >= 1) {echo $itemCount;} else {echo "0";} ?> )</li>
<li>Contact</li>
</ul>
</div>
</nav>
</header>
...and the cart class:
class cart {
public $items = array();
function __construct() {
$pdo = new pdoAccess("localhost","root","");
$counter = 0;
if (isset($_SESSION['cart'])) { foreach($_SESSION['cart'] as $item) {
$items[$counter] = $pdo->getItemDetails($item, "items");
$counter++;
}
}
}
public function emptyCart() {
session_unset();
session_destroy();
}
public function removeItem($itemID) {
$index = array_search($itemID, $_SESSION['cart']);
unset($_SESSION['cart'][$index]);
}
public function getItemCount() {
if(isset($_SESSION['cart'])) {
return count($_SESSION['cart']);
} else {
return 0;
}
}
public function getSubtotal() {
$total = 0;
foreach($items as $item) {
$total += $item->price;
}
return $total;
}
public function getDiscount() {
$sub = $this->getSubtotal();
if($this->getItemCount >= 2) {
$discount = $sub * .1;
} else {
$discount = 0;
}
return $discount;
}
public function getTotal() {
$sub = $this->getSubtotal;
if($this->getItemCount >= 2) {
$sub +- $this->getDiscount;
}
$total = $sub + SHIPPING;
return $total;
}
}
I would appreciate any help. Thanks in advance!
Back again with a new question.
I'm still working on that projects website, and i'm kind of stuck with a simple option.
Im trying to show a language flag at the menu with the current language. Just the flag, no text (maybe we'll want that later though).
Right now, the menu works like this:
user_box.php
<?php trace(__FILE__,'begin'); ?>
<div id="userbox">
<ul id="account_more_menu">
<?php if(isset($_userbox_projects) && is_array($_userbox_projects) && count($_userbox_projects)) { ?>
<li><?php echo lang('my projects') ?>
<ul>
<?php if (logged_user()->canManageProjects()) { ?>
<li><?php echo lang('add project') ?></li>
<li><?php echo lang('copy project') ?></li>
<?php } // if ?>
<li><span><?php echo lang('projects') ?>:</span></li>
<?php if(100 > count($_userbox_projects)) { ?>
<?php foreach($_userbox_projects as $_userbox_project) { ?>
<li><?php echo clean($_userbox_project->getName()) ?></li>
<?php } // foreach ?>
<?php } else { ?>
<?php foreach($_userbox_projects as $_userbox_project) { ?>
<?php $name = clean($_userbox_project->getName()) ?>
<?php $url = clean($_userbox_project->getOverviewUrl()) ?>
<?php $first = strtoupper(substr($name,0,1)); ?>
<?php if (!array_key_exists($index, $first)) $index[$first]=array(); ?>
<?php $index[$first][] = array($name, $url); ?>
<?php } // foreach ?>
<?php foreach($index as $first => $items) { ?>
<li><a href=#><?php echo $first ?></a><ul>
<?php foreach($items as $item) { ?>
<li><?php echo $item[0] ?></li>
<?php } // foreach ?>
</ul></li>
<?php } // foreach ?>
<?php } // if ?>
<?php
// PLUGIN HOOK
plugin_manager()->do_action('my_projects_dropdown');
// PLUGIN HOOK
?>
</ul>
</li>
<?php } // if ?>
<?php if (!is_null(active_project())) { ?>
<?php if (use_permitted(logged_user(), active_project(), 'tasks')) { ?>
<?php if (isset($_userbox_projects) && is_array($_userbox_projects) && count($_userbox_projects)) { ?>
<li><?php echo lang('my tasks') ?>
<ul>
<li><span><?php echo clean(active_project()->getName()) ?>:</span></li>
<li><?php echo lang('overview') ?></li>
<li class="header"><?php echo lang('messages') ?></li>
<?php if (ProjectMessage::canAdd(logged_user(), active_project())) { ?>
<li><?php echo lang('add message') ?></li>
<?php } // if ?>
<li class="header"><?php echo lang('milestones') ?></li>
<li><?php echo lang('view calendar') ?></li>
<?php if (ProjectMilestone::canAdd(logged_user(), active_project())) { ?>
<li><?php echo lang('add milestone') ?></li>
<?php } // if ?>
<?php
// PLUGIN HOOK
plugin_manager()->do_action('my_tasks_dropdown');
// PLUGIN HOOK
?>
</ul>
</li>
<?php } // if ?>
<?php } // if ?>
<?php } // if ?>
<?php if(logged_user()->isAdministrator()) { ?>
<li><?php echo lang('administration') ?>
<ul>
<li class="header"><?php echo lang('company') ?></li>
<li><?php echo lang('edit company') ?></li>
<li><?php echo lang('add contact') ?></li>
<li class="header"><?php echo lang('clients') ?></li>
<li><?php echo lang('add client') ?></li>
<li class="header"><?php echo lang('projects') ?></li>
<li class="header"><?php echo lang('configuration') ?></li>
<li class="header"><?php echo lang('plugins') ?></li>
<li class="header"><?php echo lang('administration tools') ?></li>
<li><?php echo lang('administration tool name mass_mailer' ) ?></li>
<li class="header"><?php echo lang('upgrade') ?></li>
<?php
// PLUGIN HOOK
plugin_manager()->do_action('administration_dropdown');
// PLUGIN HOOK
?>
</ul>
</li>
<?php } // if ?>
<li class="user"><?php echo lang('view') . ' ' . clean($_userbox_user->getDisplayName()) ?>
<ul>
<li><span><?php echo lang('account') ?>:</span></li>
<?php if (logged_user()->canUpdateProfile(logged_user())) { ?>
<li><?php echo lang('update profile') ?></li>
<li><?php echo lang('change password') ?></li>
<?php } // if ?>
<?php if (logged_user()->canUpdatePermissions(logged_user())) { ?>
<li><?php echo lang('update permissions') ?></li>
<?php } // if ?>
<?php
// PLUGIN HOOK
plugin_manager()->do_action('my_account_dropdown');
// PLUGIN HOOK
?>
</ul>
</li>
<li><a href=#><img src="<?php echo image_url('icons/language.gif') ?>" /></a><ul>
<li><span><?php echo lang('select language') ?>:</span></li>
<?php
$base_language = config_option('installation_base_language', 'en_us');
$languages = array( $base_language => $base_language );
include(ROOT . '/language/locales.php');
if ($handle = opendir(ROOT . '/language')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (array_key_exists( $file, $locales)) {
$languages[$file] = $locales[$file];
}
}
}
closedir($handle);
}
foreach( $languages as $locale => $desc ) {
echo '<li><a href="' . get_url('dashboard', 'index', array('language' => $locale) ) . '" >' . $desc . '</a></li>';
}
?>
</ul>
</li>
<li><a id="logout" class="js-confirm" href="<?php echo get_url('access', 'logout') ?>" title="<?php echo lang('confirm logout') ?>"><?php echo lang('logout') ?></a></li>
</ul>
</div>
<?php trace(__FILE__,'end'); ?>
As you can see it just shows a single image. And i can't seem to figure out how to change this to adjust to the language.
I usually end up with these results:
In the language file the menu options are showed, and you can change these. So i changed them using a sprite with a flag.
Sprite language menu option (locales.php):
<?php
$locales = array(
'bg_bg' => 'Bulgarian (Bulgaria)',
'cz_cz' => 'Czech',
'da_dk' => '<img src="images/blank.gif" class="flag flag-dk" alt="Danish" /> Danish',
'de_de' => '<img src="images/blank.gif" class="flag flag-de" alt="German" /> German',
'el_gr' => 'Greek',
'en_us' => '<img src="images/blank.gif" class="flag flag-gb" alt="English" /> English',
'es_ar' => 'Spanish (Argentina)',
'es_es' => '<img src="images/blank.gif" class="flag flag-es" alt="Spanish" /> Spanish',
'es_mx' => 'Spanish (Mexico)',
'fi_fi' => '<img src="images/blank.gif" class="flag flag-fi" alt="Finnish" /> Finnish',
'fr_fr' => '<img src="images/blank.gif" class="flag flag-fi" alt="Finnish" /> Finnish',
'hu_hu' => 'Hungarian (Hungary)',
'hu_if' => 'Hungarian (informal)',
'is_is' => '<img src="images/blank.gif" class="flag flag-is" alt="Icelandic" /> Icelandic',
'it_it' => '<img src="images/blank.gif" class="flag flag-it" alt="Italian" /> Italian',
'lt_lt' => 'Lithuanian (Lithuania)',
'nl_nl' => '<img src="images/blank.gif" class="flag flag-nl" alt="Dutch (Nederlands)" /> Dutch',
'no_nb' => '<img src="images/blank.gif" class="flag flag-no" alt="Norwegian" /> Norwegian',
'pl_pl' => 'Polish (Poland)',
'pt_br' => 'Portuguese (Brazil)',
'pt_pt' => 'Portuguese (Portugal)',
'ru_ru' => '<img src="images/blank.gif" class="flag flag-ru" alt="Russian" /> Russian',
'sl_si' => 'Slovenian (Slovenia)',
'sv_se' => 'Swedish (sv_se)',
'tr_tr' => 'Turkish (Turkey)',
'vn_vn' => 'Vietnamese',
'zh_cn' => '<img src="images/blank.gif" class="flag flag-cn" alt="Chinese" /> Simplified Chinese',
);
?>
CSS:
.flag {
width: 16px;
height: 11px;
background:url(/images/flags.png) no-repeat
}
.flag.flag-cn {background-position: -16px 0}
.flag.flag-de {background-position: -32px 0}
.flag.flag-dk {background-position: -48px 0}
.flag.flag-es {background-position: 0 -11px}
.flag.flag-fi {background-position: -16px -11px}
.flag.flag-gb {background-position: -32px -11px}
.flag.flag-is {background-position: -48px -11px}
.flag.flag-it {background-position: 0 -22px}
.flag.flag-nl {background-position: -16px -22px}
.flag.flag-no {background-position: -32px -22px}
.flag.flag-ru {background-position: -48px -22px}
`
Now i have tried multiple things. But I can not seem to get the right code. Basically what I want is to change the icon (dutch flag in the images) to change to the correct language flag. It would be favoured to do this by using that sprite, but if that would be too much, I could just make seperate images. I just need some help figuring out this code to make it work.
I've had a look through other's questions but couldn't see anything quite the same, so apologies if I missed one.
I created a site in a subdirectory while I was developing it before moving it to the root, on moving it to the root, access to MySQL database through php stopped working. The particular line of code that it stops at is
$pdo=new PDO("mysql:dbname=NAME;host=127.0.0.1","USERNAME","PASSWORD");
The script works fine as soon as it's moved even a single directory outside of the root. Any ideas what the issue might be?
Index
<!DOCTYPE html>
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Raleway:600,500,400' rel='stylesheet' type='text/css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link type="text/css" rel="stylesheet" href="/assets/css/ProtoStyle_1.css"/>
<?php
require_once('./php/autoloader.php');
$feed = new SimplePie('http://mywebsite.eu/blog/feed');
function returnImage ($text) {
$text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
$pattern = "/<img[^>]+\>/i";
preg_match($pattern, $text, $matches);
$text = $matches[0];
return $text;
}
function scrapeImage($text) {
$pattern = '/src=[\'"]?([^\'" >]+)[\'" >]/';
preg_match($pattern, $text, $link);
$link = $link[1];
$link = urldecode($link);
return $link;
}
?>
</head>
<?php flush(); ?>
<body onresize="setFontSize()" >
<div id="kvh_page">
<div id="kvh_header"><?php include("nav-bar.html"); ?></div>
<div id="kvh_content">
<div id="kvh_latestproject">
<div class="kvh_screen" >
<div class="kvh_page1">
<img src="/assets/images/balloons.png"/>
<h1>Current Project</h1>
</div>
<div class="kvh_page2">
<img src="/assets/images/left-right.jpg"/>
<h1>Left/Right</h1>
<h2>Left/Right is a mobile app designed to push your reaction speed to the limit.</h2>
<button type="button">More</button>
</div>
</div>
</div>
<div id="kvh_latestblog">
<div>
<div class="kvh_screen" >
<div class="kvh_page1">
<img src="/assets/images/road.png"/>
<h1>Latest Blog Post</h1>
</div>
<?php $item = $feed->get_item();
$Description = $item->get_description();
$image = returnImage($Description);
$Description = str_replace($image, "", $Description);
$image = scrapeImage($image); ?>
<div class="kvh_page2" style="background-image: url('<?php print $image; ?>')">
<span class="kvh_textmask">
<h1><?php print $item->get_title(); ?></h1>
<h2><?php print $Description; ?></h2>
<?php $author = $item->get_author(); ?>
<h3>Posted on <?php print $item->get_date('j F, Y'); ?> by <strong><?php print $author->get_name(); ?></strong></h3>
<button type="button">Read more</button>
</span>
</div>
</div>
</div>
</div>
<div id="kvh_latestresource">
<div>
<div class="kvh_screen" >
<div class="kvh_page1">
<img src="/assets/images/rain.png"/>
<h1>Thing of the day</h1>
</div>
<?php include("gethomestuff.php"); ?>
<!--<div class="kvh_page2" style="background-image: url('/assets/images/MangaDice.png')">
<span class="kvh_textmask">
<h1>This is the name of the thing</h1>
<h2>- Category</h2>
<button type="button">Check it out</button>
</span>
</div>-->
</div>
</div>
</div>
</div>
</div>
<?php include("footer.php"); ?>
<script src="/assets/scripts/proto1.js"></script>
</body>
</html>
gethomestuff
<?php
try {
$pdo=new PDO("mysql:dbname=NAME;host=127.0.0.1","USERNAME","PASSWORD");
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
$statement=$pdo->prepare("SELECT * FROM DailyStuff limit 1");
$statement->execute();
$results=$statement->fetchAll(PDO::FETCH_ASSOC);
foreach($results as $row)
{
if(strlen($row['Image']) < 10)
echo '<div class="kvh_page2">'. PHP_EOL;
else echo '<div class="kvh_page2" style="background-image: url(\''. $row['Image'] . '\')">'. PHP_EOL ;
echo '<span class="kvh_textmask">'. PHP_EOL . '<h1>'. $row['Name'].'</h1>'. PHP_EOL . '<h2>- '. $row['Category'] .'</h2>' . PHP_EOL .'<button type="button">Check it out</button>'. PHP_EOL .'</span>'. PHP_EOL .'</div>' . PHP_EOL;
}
?>
You should always check the result of all calls to the database so change that line of code to
try {
$pdo=new PDO("mysql:dbname=NAME;host=127.0.0.1","USERNAME","PASSWORD");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo 'Database connection OK';
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
This should show you the error that is being generated by the attempt to connect to the database.
i'm getting the following error.
i cant figure it out what is wrong with this code.
there is something that i missed or forget.
can anybody please help me? i'm stuck at the moment.
he keeps saying there something with the array.
Notice: Undefined property: Cms::$contant_types in C:\xampp\htdocs\PassieCMS\app\cms\models\m_cms.php on line 34
Warning: in_array() expects parameter 2 to be array, null given in C:\xampp\htdocs\PassieCMS\app\cms\models\m_cms.php on line 34
<?php
/*
CMS Class
Handle CMS task, allowing admins to view/edit content
*/
class Cms
{
private $content_types = array('wysiwyg', 'textarea', 'oneline');
private $FP;
function __construct()
{
global $FP;
$this->FP = &$FP;
}
function clean_block_id($id)
{
$id = str_replace(' ', '_', $id);
$id = str_replace('-', '_', $id);
$id = preg_replace("/[^a-zA-Z0-9_]/", '',$id);
return strtolower($id);
}
function display_block($id, $type = 'wysiwyg')
{
// clean id
$id = $this->clean_block_id($id);
// check for valid type
$type = strtolower(htmlentities($type, ENT_QUOTES));
if (in_array($type, $this->contant_types) == FALSE)
{
echo "<script>alert('Please enter a valid block type for \'" . $id . "\'');</script>";
return;
}
// get content
$content = "content here...";
// check login status
if ($this->FP->Auth-checkLoginStatus())
{
if($type == 'wysiwyg') { $type2 = 'WYSIWYG';}
if($type == 'textarea') { $type2 = 'Textarea';}
if($type == 'oneline') { $type2 = 'One Line';}
$edit_start = '<div class=""fp_edit>';
$edit_type = '<a class="fp_edit_type" href="' . SITE_PATH .'app/cms/edit.php?id' . $id . '&type='. $type . '">' . $type2 . '</a>';
$edit_link = '<a class="fp_edit_link" href="' . SITE_PATH .'app/cms/edit.php?id' . $id . '&type='. $type . '">Bewerken</a>';
$edit_end = '</div>';
echo $edit_start . $edit_type;
echo $edit_link . $content . $edit_end;
}
else
{
echo $content;
}
}
}
and the index file is
<?php include ("app/init.php");?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PassieCMS</title>
<link href="resources/css/style.css" rel="stylesheet" type="text/css">
<?php $FP->head(); ?>
</head>
<body class="home <?php $FP->body_class(); ?>">
<?php $FP->toolbar(); ?>
<div id="wrapper">
<h1>Website</h1>
<div id="banner">
<img src="resources/images/banner.jpg" alt="banner" width="900" height="140">
</div>
<ul id="nav">
<li>Home</li>
<li>Test link</li>
<li>Longer Text Link</li>
<li>Contact us</li>
</ul>
<div id="content">
<div class="left">
<h2><?php $FP->Cms->display_block('content-header','oneline'); ?></h2>
<?php $FP->Cms->display_block('content-maincontent'); ?>
</div>
<div class="right">
<?php $FP->Cms->display_block('content-quote'); ?>
<?php $FP->Cms->display_block('content-attribution'); ?>
</div>
</div>
<div id="footer">
Copyright 2014 PassieCMS | <?php $FP->login_link();?> Login optie 2
</div>
</div>
</body>
</html>
Thank you all for your time
if (in_array($type, $this->contant_types) == FALSE)
You have a typo, you have declared it as content_types above. This should work:
if (in_array($type, $this->content_types) == FALSE)