Category Archives: php

Install PEAR and add path to $PATH on Mac

Recently I was just installing PEAR and I needed to add it to $PATH. I stumbled upon site of muttsnutts notes and here is the path I’ve been following to do it:

Here is how to install PEAR:

1
2
3
$ cd /Users/robertkuzma
$ wget http://pear.php.net/go-pear.phar
$ php -d detect_unicode=0 go-pear.phar

The syntax for adding $PATH:

1
sudo sh -c 'echo "/Users/robertkuzma/pear/bin" >> /etc/paths.d/pear_path'

Eventually for PEAR to work in PHP you will also need to add the include line to php.ini file.

1
include_path=".:/Users/robertkuzma/pear/share/pear"

And how to check if pear is actually working in your PHP? You have to include System.php class because it comes embeded with PEAR.

1
2
3
4
5
6
7
8
9
10
<?php

require_once 'System.php';
if(class_exists('System')===true) {
    echo 'PEAR is installed!';
} else {
    echo 'PEAR is not installed :(';
}

?>

or a bit more simple:

1
2
3
4
5
6
<?php

require_once 'System.php';
var_dump(class_exists('System', false));

?>

Manipulating SharePoint list items with PHP

For long time I’ve been playing around in my head with the idea to be able to connect to SharePoint Web Services with some third-party tools. Finaly I googled a bit and found quite few articles about it. I liked the most the one from http://davidsit.wordpress.com.

I am also attaching the the code for php version 5.3 with built in SOAP support. The only thing I added are the HTML tags and UTF-8 charset in order to display slovenian characters properly.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Manipulating SharePoint list items with PHP</title>
</head>
<?php
//Authentication details
$authParams = array('login' => 'yourUsername', 'password' => 'yourPassword');

/* A string that contains either the display name or the GUID for the list.
 * It is recommended that you use the GUID, which must be surrounded by curly
 * braces ({}).
 */

$listName = "TempList";
$rowLimit = '150';

/* Local path to the Lists.asmx WSDL file (localhost). You must first download
 * it manually from your SharePoint site (which should be available at
 * yoursharepointsite.com/subsite/_vti_bin/Lists.asmx?WSDL)
 */

$wsdl = "http://localhost/_vti_bin/Lists.asmx?WSDL";

//Creating the SOAP client and initializing the GetListItems method parameters
$soapClient = new SoapClient($wsdl, $authParams);
$params = array('listName' => $listName, 'rowLimit' => $rowLimit);

//Calling the GetListItems Web Service
$rawXMLresponse = null;
try{
    $rawXMLresponse = $soapClient->GetListItems($params)->GetListItemsResult->any;
}
catch(SoapFault $fault){
    echo 'Fault code: '.$fault->faultcode;
    echo 'Fault string: '.$fault->faultstring;
}
echo '<pre>' . $rawXMLresponse . '</pre>';

//Loading the XML result into parsable DOM elements
$dom = new DOMDocument();
$dom->loadXML($rawXMLresponse);
$results = $dom->getElementsByTagNameNS("#RowsetSchema", "*");

//Fetching the elements values. Specify more attributes as necessary
foreach($results as $result){
    echo $result->getAttribute("ows_LinkTitle")."<br/>";
}
unset($soapClient);
?>
<body>
</body>
</html>

In the article from David Dudok de Wit you will also find a solution for older PHP versions. You just have to include nusoap.php library

Joomla 1.5 Latest News Scroller Module

I have been searching for module similar to mod_scroll_news in Joomla 1.0 but was not able to find it anywhere. So i took the code from the already existing mod_latestnews and made few changes to it. It works for what I need just fine.

Maybe I will spend some more time on it and tweek it a bit to have some more custom settings …

It will display the title as a link and the contents of the articles in the section/category specified.

You can download the module here: mod_newscroller.