How to remove Moodle Logo in version 2.8 - moodle

Have just created a new Moodle page documentation. However, I would like to remove the Moodle logo that is shown in the footer. How can that be achieved? I have tried looking in admin/styles directory and also to try to change the image in pix/ moodlelogo.gif directory. However, none of those method seems to work.

There are two solutions:
I. First (hack Moodle core):
go to [moodle dir]\lib\outputrenderers.php
find public function home_link()
and replace it code:
public function home_link() {
global $CFG, $SITE;
if ($this->page->pagetype == 'site-index') {
// Special case for site home page - please do not remove
return '';
} else if (!empty($CFG->target_release) && $CFG->target_release != $CFG->release) {
// Special case for during install/upgrade.
return '';
} else if ($this->page->course->id == $SITE->id || strpos($this->page->pagetype, 'course-view') === 0) {
return '<div class="homelink"><a href="' . $CFG->wwwroot . '/">' .
get_string('home') . '</a></div>';
} else {
return '<div class="homelink"><a href="' . $CFG->wwwroot . '/course/view.php?id=' . $this->page->course->id . '">' .
format_string($this->page->course->shortname, true, array('context' => $this->page->context)) . '</a></div>';
}
}
II. Second (simple hide logo):
Add to your css file (for example "custom.css") next lines :
.sitelink {
display: none;
}
But remember: deleting moodle logo (free open source software) not good idea!

Related

get pagename in my wordpress plugin

I am adding specific js file to the front end from my wordpress plugin.
For Example :
if($wp->query_vars["pagename"] == 'pagename1'){
include js file 1.
}else if($wp->query_vars["pagename"] == 'pagename1'){
include js file 2.
}
But now i am not able to get the page name in$wp->query_vars.
Thank you
Balaji
Try this:
$post = get_post();
$post_name = $post->post_name;
To add javascript you could do this:
add_action( 'wp_enqueue_scripts', 'addSomescripts' );
function addSomeScripts() {
$post = get_post( );
$post_name = $post->post_name;
if($post_name == 'pagename1') {
wp_enqueue_script('script1', '/pathtoscript1.js');
} else if($post_name == 'pagename2') {
wp_enqueue_script('script2', '/pathtoscript2.js');
}
}

Auto complete/Suggest in Wordpress Form

I'm placing a search form of 6 fields on my home page which includes a text box field named course. I want to show course suggestions while user typing. One more is, I want to show/hide some fields according to the option of first field dropdown. Any help would be appreciated.
You can use jQuery Auto Suggest which is included with WordPress : wp_enqueue_script
With this you can write a form that does a Ajax lookup to the the Ajax URL handler. Which you can add_action onto. AJAX in Plugins
So you can ajax lookup and then on the action side you can just perform a get_posts to match titles, or a raw sql Query. And return what is needed. edit your functions.php.
add_action('wp_enqueue_scripts', 'se_wp_enqueue_scripts');
function se_wp_enqueue_scripts() {
wp_enqueue_script('suggest');
}
add_action('wp_head', 'se_wp_head');
function se_wp_head() {
?>
<script type="text/javascript">
var se_ajax_url = '<?php echo admin_url('admin-ajax.php'); ?>';
jQuery(document).ready(function() {
jQuery('#se_search_element_id').suggest(se_ajax_url + '?action=se_lookup');
});
</script>
<?php
}
add_action('wp_ajax_se_lookup', 'se_lookup');
add_action('wp_ajax_nopriv_se_lookup', 'se_lookup');
function se_lookup() {
global $wpdb;
$search = like_escape($_REQUEST['q']);
$query = 'SELECT ID,post_title FROM ' . $wpdb->posts . '
WHERE post_title LIKE \'' . $search . '%\'
AND post_type = \'post_type_name\'
AND post_status = \'publish\'
ORDER BY post_title ASC';
foreach ($wpdb->get_results($query) as $row) {
$post_title = $row->post_title;
$id = $row->ID;
$meta = get_post_meta($id, 'YOUR_METANAME', TRUE);
echo $post_title . ' (' . $meta . ')' . "\n";
}
die();
}
Use ajax for both. You may have to write some mysql query to retrieve the required fields(post titles or whatever it is) from the table.

How to include js and css in Zend Form Elements?

I create my own zend form element - App_Form_Element_Wysiwyg
<?php
class App_Form_Element_Wysiwyg extends Zend_Form_Element_Xhtml
{
/**
* Default form view helper to use for rendering
* #var string
*/
public $helper = 'wysiwyg';
}
Then I create helper for wysiwyg - App_View_Helper_Wysiwyg
<?php
class App_View_Helper_Wysiwyg extends Zend_View_Helper_FormTextarea
{
public function wysiwyg($name, $value = null, $attribs = null)
{
// Here I want to include js and css for wysiwyg editor
...
$xhtml = '<textarea name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. $disabled
. $this->_htmlAttribs($attribs) . '>'
. $this->view->escape($value) . '</textarea>';
return $xhtml;
}
}
How can I include js and css files for wysiwyg editor?
The headScript() helper lets you add or manipulate script tags in the header. So within your helper you can do:
$this->view->headScript()->appendFile('/path/to/file.js');
then just ensure your layout is calling the helper somewhere in the head section:
<?=$this->headScript()?>
to output the HTML. There is also the headStyle() helper which works in a similar way and can be used for your CSS.
Relevant docs:
HeadScript
HeadStyle

Zend_navigation & Zend_translate href attribute dont switch with language change

I have a zend framework project with zend version 1.12.
I´m using zend_navigation with a xml file and zend_translation with the gettext adapter.
This code creates the main menu:
echo '<ul class="nav1">';
foreach ($this->container as $page) {
// check if it is active (not recursive)
$isActive = $page->isActive(false);
$liClass = $isActive ? ' class="active"' : '';
echo '<li ' . $liClass . '>' . $this->menu()->htmlify($page);
// subnavigation in second layer
if (sizeof($page) > 0) {
echo '<ul class="subNavHead">';
foreach ($page as $subpage) {
$isActive = $subpage->isActive(false);
$liClass = $isActive ? ' class="active"' : '';
echo '<li ' . $liClass . '>' . $this->menu()->htmlify($subpage) . '</li>';
}
echo '</ul>';
}
echo '</li>';
}
echo '</ul>';
And here is my language selector class:
class AW_Controller_Plugin_LangSelector extends Zend_Controller_Plugin_Abstract {
public function preDispatch(Zend_Controller_Request_Abstract $request) {
$lang = $request->getParam('lang', '');
if ($lang !== 'de' && $lang !== 'en' && $lang !== 'pl')
$request->setParam('lang', 'de');
switch ($request->getParam('lang')) {
case 'de':
$locale = 'de';
break;
case 'en':
$locale = 'en';
break;
case 'pl':
$locale = 'pl';
break;
default :
$locale = 'de';
break;
}
$zl = new Zend_Locale();
$zl->setLocale($locale);
Zend_Registry::set('Zend_Locale', $zl);
$translate = Zend_Registry::get('Zend_Translate');
$translate->setLocale($zl);
}
}
When I change the language with a select box the text on my site change the language, but the navigation targets don´t change. The navigationlabels changes too.
When I am in default language :
www.example.de/de/controller/action
And then I switch the language to English
-> the href attributes of my navigation are still on the old value (www.example.de/de/controller/action) but they should have www.example.de/en/controller/action
Where is my problem? Have I forget to re-render the menu?
I believe you are saying that the labels ('Home', 'Contact Us') are changing, but the links ('/', '/contact-us') aren't. The way Zend_Menu uses Zend_Translate only for the menu labels.
If your menu is created by MVC instead of URIs, you can make it take your language values by adding the line
$page->setParam('lang', Zend_Registry::get('Zend_Locale')->getLocale());
This would go in your navigation render, between "foreach ($page as $subpage) {" and "echo".
If your menu is using URIs, you can do a substitution on the page HREF at the same point.
Now, if I've misunderstood your question, and it's not translating links OR labels in the menu, then check and see if your menu is executing before your plugin's preDispatch.

Displaying images in atom feed

I have problems with displaying images in atom file. It doesn't include images in feed in google reader, opera or firefox.
As a starting point I did everything like in Listing 6. at [An overview of the Atom 1.0 Syndication Format] But it doesn't work.
Update
It is not problem with hotlink protected images. Described here: How to display item photo in atom feed?
Later I changed feed according to description posted here.
I added:
<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="path_to_image.jpg" />
But still it doesn't work
I had the same problem when trying to include images as enclosure, but it seemed that the easiest way for me was to include the image with the normal img tag to the html content.
(It's also wrapped in CDATA, which might affect the way Google Reader handles the content. I haven't tried without.)
The following example works for me to make atom feed images visible in Google Reader:
<content type="html">
<![CDATA[
<a href="http://test.lvh.me:3000/listings/341-test-pics?locale=en">
<img alt="test_pic" src="http://test.lvh.me:3000/system/images/20/medium/test_pic.jpg?1343246102" />
</a>
]]>
</content>
Wordpress uses the metafield enclosure to set the medias. This is the correct tag according to RSS specification. I have seen people suggest using media:content but if using that make sure to set the XML namespace for it.
Unfortunately due to some dodgy Wordpress code you can not set this dynamically. (Wordpress gets all metafields and then loops through them instead of calling the enclosure directly)
You can set the enclosure on save post. It should be an array with entries of the form "$url\n$length\n$type"
If you want to add the enclosure tags yourself you can do the following:
RSS
add_action( 'rss2_item', 'hughie_rss2_item_enclosure' );
function hughie_rss2_item_enclosure():void
{
$id = get_post_thumbnail_id();
$url = wp_get_attachment_url($id);
$length = filesize(get_attached_file($id));
$type = get_post_mime_type($id);
echo apply_filters( 'rss_enclosure', '<enclosure url="' . esc_url( $url ) . '" length="' . absint( $length ) . '" type="' . esc_attr( $type ) . '" />' . "\n" );
}
ATOM:
add_action( 'atom_entry', 'hughie_atom_entry_enclosure' );
function hughie_atom_entry_enclosure():void
{
$id = get_post_thumbnail_id();
$url = wp_get_attachment_url($id);
$length = filesize(get_attached_file($id));
$type = get_post_mime_type($id);
echo apply_filters( 'atom_enclosure', '<link rel="enclosure" href="' . esc_url( $url ) . '" length="' . absint( $length ) . '" type="' . esc_attr( $type ) . '" />' . "\n" );
}
The only way I found to set the enclosure dynamically is short-circuiting the get_metadata call. You can add checks to make sure that you are in a feed or even the check the stacktrace to make sure.
add_filter('get_post_metadata', 'hughie_get_post_metadata', 10, 5 );
function hughie_get_post_metadata($value, int $object_id, string $meta_key, bool $single, string $meta_type)
{
if (is_feed() && $meta_key === '') {
$backtrace = debug_backtrace();
if (isset($backtrace[7]['function']) && ( $backtrace[7]['function'] === 'rss_enclosure' || $backtrace[7]['function'] === 'atom_enclosure' ) ) {
if (!isset($value['enclosure'])) {
$value['enclosure'] = [];
}
$id = get_post_thumbnail_id();
$url = wp_get_attachment_url($id);
$length = filesize(get_attached_file($id));
$type = get_post_mime_type($id);
$value['enclosure'][] = "$url\n$length\n$type";
}
}
return $value;
}