svn: /pear/pearweb/trunk/include/pepr/ pepr-pplink.php pepr.php

From: Date: Fri, 18 Mar 2011 15:52:40 +0000
Subject: svn: /pear/pearweb/trunk/include/pepr/ pepr-pplink.php pepr.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-9807@lists.php.net to get a copy of this message
till Fri, 18 Mar 2011 15:52:40 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=309394 Log: spin off class pplink Changed paths: A + pear/pearweb/trunk/include/pepr/pepr-pplink.php (from pear/pearweb/trunk/include/pepr/pepr.php:r309393) U pear/pearweb/trunk/include/pepr/pepr.php Copied: pear/pearweb/trunk/include/pepr/pepr-pplink.php (from rev 309393, pear/pearweb/trunk/include/pepr/pepr.php) =================================================================== --- pear/pearweb/trunk/include/pepr/pepr-pplink.php (rev 0) +++ pear/pearweb/trunk/include/pepr/pepr-pplink.php 2011-03-18 15:52:40 UTC (rev 309394) @@ -0,0 +1,84 @@ +<?php +/** + * Establishes the procedures, objects and variables used throughout PEPr. + * + * The <var>$proposalTypeMap</var> arrays is defined here. + * + * NOTE: Proposal constants are defined in pearweb/include/pear-config.php. + * + * This source file is subject to version 3.0 of the PHP license, + * that is bundled with this package in the file LICENSE, and is + * available through the world-wide-web at the following URI: + * http://www.php.net/license/3_0.txt. + * If you did not receive a copy of the PHP license and are unable to + * obtain it through the world-wide-web, please send a note to + * license@php.net so we can mail you a copy immediately. + * + * @category pearweb + * @package PEPr + * @author Tobias Schlitt <toby@php.net> + * @author Daniel Convissor <danielc@php.net> + * @copyright Copyright (c) 1997-2005 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License + * @version $Id$ + */ + +global $proposalTypeMap; +$proposalTypeMap = array( + 'pkg_file' => "PEAR package file (.tgz)", + 'pkg_source' => "Package source file (.phps/.htm)", + 'pkg_example' => "Package example (.php)", + 'pkg_example_source' => "Package example source (.phps/.htm)", + 'pkg_doc' => "Package documentation"); + +class ppLink +{ + var $pkg_prop_id; + var $type; + var $url; + + function __construct($dbhResArr) + { + foreach ($dbhResArr as $name => $value) { + $this->$name = $value; + } + } + + function &getAll(&$dbh, $proposalId) + { + $sql = 'SELECT * FROM package_proposal_links WHERE pkg_prop_id = ? ORDER BY type'; + $res = $dbh->query($sql, array($proposalId)); + if (DB::isError($res)) { + return $res; + } + $links = array(); + while ($set = $res->fetchRow(DB_FETCHMODE_ASSOC)) { + $links[] = new ppLink($set); + } + return $links; + } + + function deleteAll($dbh, $proposalId) + { + $sql = 'DELETE FROM package_proposal_links WHERE pkg_prop_id = ?'; + $res = $dbh->query($sql, array($proposalId)); + return $res; + } + + function store($dbh, $proposalId) + { + $sql = "INSERT INTO package_proposal_links (pkg_prop_id, type, url) + VALUES (".$proposalId.", ".$dbh->quoteSmart($this->type).", ".$dbh->quoteSmart($this->url).")"; + $res = $dbh->query($sql); + return $res; + } + + function getType($humanReadable = false) + { + if ($humanReadable) { + return $GLOBALS['proposalTypeMap'][$this->type]; + } + + return $this->type; + } +} Modified: pear/pearweb/trunk/include/pepr/pepr.php =================================================================== --- pear/pearweb/trunk/include/pepr/pepr.php 2011-03-18 15:50:04 UTC (rev 309393) +++ pear/pearweb/trunk/include/pepr/pepr.php 2011-03-18 15:52:40 UTC (rev 309394) @@ -3,8 +3,6 @@ /** * Establishes the procedures, objects and variables used throughout PEPr. * - * The <var>$proposalTypeMap</var> arrays is defined here. - * * NOTE: Proposal constants are defined in pearweb/include/pear-config.php. * * This source file is subject to version 3.0 of the PHP license, @@ -115,63 +113,4 @@ require_once __DIR__ . '/pepr-proposal.php'; require_once __DIR__ . '/pepr-ppcomment.php'; require_once __DIR__ . '/pepr-ppvote.php'; - -global $proposalTypeMap; -$proposalTypeMap = array( - 'pkg_file' => "PEAR package file (.tgz)", - 'pkg_source' => "Package source file (.phps/.htm)", - 'pkg_example' => "Package example (.php)", - 'pkg_example_source' => "Package example source (.phps/.htm)", - 'pkg_doc' => "Package documentation"); - -class ppLink -{ - var $pkg_prop_id; - var $type; - var $url; - - function __construct($dbhResArr) - { - foreach ($dbhResArr as $name => $value) { - $this->$name = $value; - } - } - - function &getAll(&$dbh, $proposalId) - { - $sql = 'SELECT * FROM package_proposal_links WHERE pkg_prop_id = ? ORDER BY type'; - $res = $dbh->query($sql, array($proposalId)); - if (DB::isError($res)) { - return $res; - } - $links = array(); - while ($set = $res->fetchRow(DB_FETCHMODE_ASSOC)) { - $links[] = new ppLink($set); - } - return $links; - } - - function deleteAll($dbh, $proposalId) - { - $sql = 'DELETE FROM package_proposal_links WHERE pkg_prop_id = ?'; - $res = $dbh->query($sql, array($proposalId)); - return $res; - } - - function store($dbh, $proposalId) - { - $sql = "INSERT INTO package_proposal_links (pkg_prop_id, type, url) - VALUES (".$proposalId.", ".$dbh->quoteSmart($this->type).", ".$dbh->quoteSmart($this->url).")"; - $res = $dbh->query($sql); - return $res; - } - - function getType($humanReadable = false) - { - if ($humanReadable) { - return $GLOBALS['proposalTypeMap'][$this->type]; - } - - return $this->type; - } -} +require_once __DIR__ . '/pepr-pplink.php';

« previous php.pear.core (#9807) next »