Exemple #1
0
 /**
  * Sets up a session handler
  * @param string $class name of the handler class 
  */
 protected static function setupHandler($class)
 {
     Pfw_Loader::loadClass($class);
     $a = new $class();
     session_set_save_handler(array($a, 'open'), array($a, 'close'), array($a, 'read'), array($a, 'write'), array($a, 'destroy'), array($a, 'gc'));
     self::$adapter = $a;
 }
Exemple #2
0
 /**
  * Returns an instance of a Pfw_Db_Adapter
  * 
  * @param $route the name of the route
  * @param $reuse
  * @return Pfw_Db_Adapter
  */
 public static function factory($route = null, $reuse = true)
 {
     if (null === $route) {
         if (!isset(self::$default_router)) {
             Pfw_Loader::loadClass('Pfw_Db_Router_Standard');
             self::$default_router = new Pfw_Db_Router_Standard(self::DEFAULT_ROUTE_NAME);
         }
         $route = self::$default_router->getWriteRoute();
     }
     if (true == $reuse) {
         $reuse_key = self::_genCnxKey($route);
         if (isset(self::$_connections[$reuse_key])) {
             self::$_connections[$reuse_key]->isSharedCnx(true);
             return self::$_connections[$reuse_key];
         }
     }
     $adapter_key = strtolower($route['adapter']);
     if (!isset(self::$_supported_adapters[$adapter_key])) {
         Pfw_Loader::loadClass('Pfw_Exception_Db');
         throw new Pfw_Exception_Db("Adapter type {$route['adapter']} is unsupported");
     }
     $class = 'Pfw_Db_Adapter_' . $route['adapter'];
     Pfw_Loader::loadClass($class);
     $instance = new $class($route);
     if (true == $reuse) {
         self::$_connections[$reuse_key] = $instance;
         self::$_connections[$reuse_key]->isSharedCnx(true);
     } else {
         $instance->isSharedCnx(false);
     }
     return $instance;
 }
Exemple #3
0
 public function validate($save_method)
 {
     Pfw_Loader::loadClass('Pfw_Validate');
     $pfv = new Pfw_Validate($this);
     if (Pfw_Model::SAVE_INSERT == $save_method) {
         $pfv->presence('name', "required!");
         $pfv->presence('description', "required!");
     }
     return $pfv->success();
 }
Exemple #4
0
 /**
  * Initialize the request. If adapter is null,
  * Pfw_Request_Standard will be used.
  * 
  * @param string $adapter the adapter class
  */
 public static function init($adapter = null)
 {
     if (!is_null($adapter)) {
         self::$adapter = $adapter;
     } else {
         $adapter_class = "Pfw_Request_Standard";
         Pfw_Loader::loadClass($adapter_class);
         self::$adapter = new $adapter_class();
     }
 }
 public static function initFromCache($cache_plugins)
 {
     foreach ($cache_plugins as $phase => $plugins) {
         foreach ($plugins as $plugin) {
             $class = $plugin['class'];
             Pfw_Loader::loadClass($class);
             $inst = new $class();
             $i =& $inst;
             array_push(self::$plugins[$phase], array('inst' => $i, 'name' => $plugin['name']));
         }
     }
     objp(self::$plugins);
     return true;
 }
Exemple #6
0
 public function createInstance($template, $replacements)
 {
     if (!is_file($template) and !is_link($template)) {
         Pfw_Loader::loadClass('Pfw_Exception_Script');
         throw new Pfw_Exception_Script(Pfw_Exception_Script::E_FS_NOT_FOUND, $template);
     }
     if (false === ($ctnt = file_get_contents($template))) {
         Pfw_Loader::loadClass('Pfw_Exception_Script');
         throw new Pfw_Exception_Script(Pfw_Exception_Script::E_FS_UNKNOWN, "Failed to get the contents of file '{$template}'.");
     }
     foreach ($replacements as $name => $value) {
         $ctnt = preg_replace("/\\\$\\{{$name}\\}/", $value, $ctnt);
     }
     return $ctnt;
 }
Exemple #7
0
 public function validate($save_method)
 {
     Pfw_Loader::loadClass('Pfw_Validate');
     $pfv = new Pfw_Validate($this);
     if (Pfw_Model::SAVE_INSERT == $save_method) {
         $pfv->presence('first_name', "required!");
         $pfv->presence('last_name', "required!");
         $pfv->presence('email', "required!");
         $pfv->email('email', "Email is invalid!");
         $pfv->presence('password', "required!");
         if ($pfv->presence('email', "required!")) {
             $email_user = User::Q()->getByEmail($this->email)->exec();
             if (!empty($email_user)) {
                 $this->addError('email', "email is taken");
                 $pfv->fail();
             }
         }
     }
     return $pfv->success();
 }
Exemple #8
0
 /**
  * Returns an instance of the local cache driver
  * 
  * @return Pfw_Cache|null instance of a Pfw_Cache object or null if none
  * is configured
  */
 public static function getInstance()
 {
     if (!is_null(self::$instance)) {
         return self::$instance;
     }
     if (null == ($local_cache = Pfw_Config::get('local_cache'))) {
         return null;
     }
     if (is_array($local_cache)) {
         $class = $local_cache['class'];
         unset($local_cache['class']);
         $options = $local_cache;
     } else {
         $class = $local_cache;
         $options = array();
     }
     Pfw_Loader::loadClass($class);
     self::$instance = new $class($options);
     return self::$instance;
 }
Exemple #9
0
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 * @filesource
 */
Pfw_Loader::loadClass('Pfw_Exception_System');
/**
 * Short description for file
 *
 * Long description for file (if any)...
 * 
 * @category      Framework
 * @package       Pfw
 */
class Pfw_Exception_Model extends Pfw_Exception_System
{
}
Exemple #10
0
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 * @filesource
 */
Pfw_Loader::loadClass('Pfw_Db_Router');
/**
 * Short description for file
 *
 * Long description for file (if any)...
 * 
 * @category      Framework
 * @package       Pfw
 */
class Pfw_Db_Router_Fixed extends Pfw_Db_Router
{
    protected $route;
    public function __construct($route)
    {
        $this->route = $route;
    }
    public function getReadRoute()
    {
        return $this->route;
/**
 * Short description for file
 *
 * Long description for file (if any)...
 *
 * @category      Framework
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 */
function smarty_function_form_field($params, &$smarty)
{
    list($args, $attrs) = $smarty->_filterAttrs($params);
    $obj_prop = $args['prop'];
    if ($args['confirmation']) {
        $obj_prop = $obj_prop . "_confirm";
    }
    if (array_key_exists('value', $args)) {
        $attrs['value'] = $args['value'];
    }
    if (array_key_exists('index', $args)) {
        $args['for'] = $args['for'] . "[{$args['index']}]";
    }
    $obj_path = $args['for'];
    if (empty($obj_path)) {
        error_log("missing required template variable name 'for'");
    }
    // get the value of the property
    $var = "";
    if (false === strpos($obj_path, '[')) {
        $var = $obj_path;
        $obj = $smarty->get_template_vars($var);
    } else {
        preg_match("/^([\\w]+)\\[?/", $obj_path, $matches);
        $var = $matches[1];
        $obj_path = str_replace($var, 'obj', $obj_path);
        // not sure if this is needed
        $obj_path = preg_replace('/\\[(?!\')/', '[\'', $obj_path);
        $obj_path = preg_replace('/\\](?<!\')/', '\']', $obj_path);
        $e = "return \${$obj_path};";
        $obj = $smarty->get_template_vars($var);
        $obj = eval($e);
    }
    if (empty($obj)) {
        Pfw_Loader::loadClass('Pfw_Form');
        $obj = new Pfw_Form();
    }
    $element = "input";
    $content = null;
    if (!isset($args['type'])) {
        if (method_exists($obj, 'getSchema')) {
            $schema = $obj->getSchema();
            switch ($schema[$obj_prop]['type']) {
                case Pfw_Db_Adapter::TYPE_CHARACTER:
                case Pfw_Db_Adapter::TYPE_INTEGER:
                case Pfw_Db_Adapter::TYPE_FLOAT:
                case Pfw_Db_Adapter::TYPE_ENUM:
                    $attrs['type'] = "text";
                    if (!isset($attrs['size'])) {
                        $attrs['size'] = 3;
                    }
                    break;
                case Pfw_Db_Adapter::TYPE_TEXT:
                    $attrs['type'] = "textarea";
                    break;
                case Pfw_Db_Adapter::TYPE_VARCHAR:
                    $attrs['type'] = "text";
                    if (!isset($attrs['size'])) {
                        $attrs['size'] = 32;
                    }
                    break;
                case Pfw_Db_Adapter::TYPE_DATE:
                    break;
                case Pfw_Db_Adapter::TYPE_TIME:
                    break;
            }
        } else {
            $attrs['type'] = "text";
        }
    } else {
        $attrs['type'] = $args['type'];
    }
    if (!isset($attrs['value']) and isset($obj->{$obj_prop})) {
        if (is_object($obj)) {
            $attrs['value'] = $obj->{$obj_prop};
        } elseif (is_array($obj) and isset($obj[$obj_prop])) {
            $attrs['value'] = $obj[$obj_prop];
        }
    }
    if (!array_key_exists('value', $attrs)) {
        if (array_key_exists('default_value', $args)) {
            $attrs['value'] = $args['default_value'];
        } else {
            $attrs['value'] = "";
        }
    }
    if ($attrs['type'] == 'checkbox') {
        if ($attrs['value']) {
            $attrs['checked'] = "1";
        }
        $attrs['value'] = 1;
    }
    /*
    elseif (empty($attrs['value'])) {
        $attrs['value'] = "";
    }
    */
    if ('textarea' == $attrs['type']) {
        $element = "textarea";
        $content = $attrs['value'];
        unset($attrs['type']);
        unset($attrs['value']);
    } elseif ('select' == $attrs['type']) {
        $element = "select";
        $content = "\n";
        if (empty($params['options'])) {
            $params['options'] = array();
        }
        $options = array_to_hash($params['options']);
        foreach ($options as $label => $value) {
            $label = empty($label) ? $value : $label;
            $selected = "";
            if ($value == $attrs['value']) {
                $selected = " selected";
            }
            $value = urlencode($value);
            $content .= "<option value=\"{$value}\"{$selected}>{$label}</option>\n";
        }
        unset($attrs['type']);
        unset($attrs['value']);
    }
    $attrs['name'] = "{$args['for']}[{$obj_prop}]";
    $err_list = "";
    if (is_object($obj) and method_exists($obj, 'hasErrors') and $obj->hasErrors($args['prop']) and false !== $args['highlight_errors']) {
        if (isset($attrs['class'])) {
            $attrs['class'] = "{$attrs['class']} pfw-error";
        } else {
            $attrs['class'] = "pfw-error";
        }
    }
    $field = $smarty->_generateElement($element, $attrs, $content);
    return $err_list . $field;
}
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @category      Framework
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2008 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 */
require '../../Pfw/UnitTest/PHPUnit/FwkTestCase.php';
Pfw_Loader::loadClass('Pfw_Controller_Router_Standard');
class Pfw_Controller_Router_Standard_Test extends Pfw_UnitTest_PHPUnit_FwkTestCase
{
    function testBasic()
    {
        $pfw_routes = array('basic_route' => array('/:controller/:action', array('action' => 'index')));
        $router = new Pfw_Controller_Router_Standard();
        $router->setRoutes($pfw_routes);
        $route = $router->route('/home/stuff');
        $this->assertEquals(array('controller' => 'home', 'action' => 'stuff'), $route);
        $this->assertEquals('basic_route', $router->getSuccessRouteName());
    }
    function testBasicConds()
    {
        $pfw_routes = array('basic_route' => array('/:controller/:action/:var', null, array('var' => 'me')));
        $router = new Pfw_Controller_Router_Standard();
Exemple #13
0
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 * @filesource
 */
Pfw_Loader::loadClass('Pfw_Db');
Pfw_Loader::loadClass('Pfw_Db_Expr');
Pfw_Loader::loadClass('Pfw_Db_Router_Standard');
Pfw_Loader::loadClass('Pfw_Cache_Dist');
Pfw_Loader::loadClass('Pfw_Session_Handler');
/**
 * Short description for file
 *
 * Long description for file (if any)...
 * 
 * @category      Framework
 * @package       Pfw
 */
class Pfw_Session_DistCacheDb implements Pfw_Session_Handler
{
    const CACHE_PREFIX = "_pfw_sess_";
    const CACHE_TTL = 600;
    const DEFAULT_DB_TABLE = 'sessions';
    protected $config;
    protected $sessions = array();
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @category      Framework
 * @package       Pfw
 * @author        Sean Sitter <sean@picnicphp>
 * @copyright     2008 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 */
require '../../Pfw/UnitTest/PHPUnit/FwkTestCase.php';
Pfw_Loader::loadClass('Pfw_Script_Template');
class Pfw_Script_Template_Test extends Pfw_UnitTest_PHPUnit_FwkTestCase
{
    function getTplDir()
    {
        return dirname(__FILE__) . DIRECTORY_SEPARATOR . 'misc' . DIRECTORY_SEPARATOR;
    }
    function testReplace()
    {
        $tpl_file = $this->getTplDir() . "script_test_template.txt";
        $ctnt = Pfw_Script_Template::createInstance($tpl_file, array('TEST_VAR' => 'FUN $STUFF'));
        $this->assertEquals('This is my new FUN $STUFF', $ctnt);
    }
    function testMissingFile()
    {
        $tpl_file = $this->getTplDir() . "junk.txt";
Exemple #15
0
 /**
  * Throws a Pfw_Exception_NotImplemented. 
  * Must be implemented in a subclass.
  */
 public function validate()
 {
     Pfw_Loader::loadClass('Pfw_Exception_NotImplemented');
     throw new Pfw_Exception_NotImplemented("you must subclass Pfw_Form and implement the validate method");
 }
Exemple #16
0
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 * @filesource
 */
Pfw_Loader::loadClass('Pfw_Exception_Script');
Pfw_Loader::loadClass('Pfw_Script_Message');
Pfw_Loader::loadClass('Pfw_Script_CLI');
Pfw_Loader::loadClass('Pfw_Exception_Script');
/**
 * Short description for file
 *
 * Long description for file (if any)...
 * 
 * @category      Framework
 * @package       Pfw
 */
class Pfw_Script_FileSystem
{
    public static function exists($path)
    {
        if (file_exists($path)) {
            return true;
        }
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @category      Framework
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2008 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 */
require '../../Pfw/UnitTest/PHPUnit/FwkTestCase.php';
Pfw_Loader::loadInclude('Pfw_Core_Base');
Pfw_Loader::loadClass('Pfw_Db_Adapter_Mysqli');
class Pfw_Db_Adapter_Mysqli_Test extends Pfw_UnitTest_PHPUnit_FwkTestCase
{
    public function setup()
    {
        $this->createTables();
    }
    public function tearDown()
    {
        $this->dropTables();
    }
    public function testSprintfEsc()
    {
        $cnx = $this->getCnx();
        $user = '******';
        $welcome = $cnx->_sprintfEsc(array("hello %s", $user));
Exemple #18
0
 <?php 
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 * @filesource
 */
Pfw_Loader::loadClass('Archive_Tar', 'ThirdParty');
/**
 * Short description for file
 *
 * Long description for file (if any)...
 * 
 * @category      Framework
 * @package       Pfw
 */
class Pfw_Script_Archive
{
    public static function expand($path)
    {
        $path = realpath($path);
        $dir = dirname($path);
        #print ">> $path\n";
        $arch = new Archive_Tar($path, true);
        $arch->setErrorHandling(PEAR_ERROR_PRINT);
        if (false === $arch->extract($dir)) {
            throw new Pfw_Exception_Script(Pfw_Exception_Script::E_ARCHIVE_UNKNOWN);
Exemple #19
0
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 * @filesource
 */
Pfw_Loader::loadClass('Pfw_Controller_Router_Base');
/**
 * Given a set of routes and a url path, attempts to path to route &
 * decomposes path into a set of variables defined in the route
 * 
 * @category      Framework
 * @package       Pfw
 */
class Pfw_Controller_Router_Standard extends Pfw_Controller_Router_Base
{
    protected $route = array();
    /**
     * Gets the conditions portion of a given route
     *
     * @param array $route  the route
     * @return array  the conditions portion of the given route
     */
    protected function _getRouteConditions($route_name, $route)
    {
Exemple #20
0
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 * @filesource
 */
Pfw_Loader::loadClass('Pfw_Associate');
/**
 * Implements an application join strategy base on the association of the
 * objects which will be association according to their association description.
 * 
 * @category      Framework
 * @package       Pfw
 */
class Pfw_Associate_PostQuery implements Pfw_Associate
{
    /**
     * Execute association strategy. Maps the associated objects into
     * each object in the array according to the object's association 
     * description. All object in the array must be instances of Pfw_Model,
     * and must be of the same type.
     * 
     * @param array &$objects the objects into wich the associations will be mapped
     * @param string $association the association to execute on the collection
     * @param $params extra options
Exemple #21
0
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 * @filesource
 */
Pfw_Loader::loadClass('Prj_Smarty_Standard');
/**
 * This class is default parent class of all controllers in your project.
 * It implements a number of convenience methods which simplify basic
 * tasks.
 * 
 * @category      Framework
 * @package       Pfw
 */
class Pfw_Controller_Standard
{
    protected $front_controller = null;
    protected $smarty = null;
    protected $config = null;
    protected $params = array();
    public function __construct()
    {
        $this->setupView();
    }
Exemple #22
0
<?php

Pfw_Loader::loadClass('Pfw_UnitTest_PHPUnit_TestCase');
Pfw_Loader::loadModel('User');
class User_Test extends Pfw_UnitTest_PHPUnit_TestCase
{
    protected function setup()
    {
        // runs before every test
    }
    protected function tearDown()
    {
        // runs after every test
    }
    public function testLogin()
    {
        $u = new User();
        $first_name = 'phpunit_' . uniqid();
        $u->first_name = $first_name;
        $u->last_name = "smith";
        $u->email = $first_name . '@example.com';
        $u->password = '******';
        $u->password_confirm = 'toast';
        $u_id = $u->save();
        # check username password validation
        $u2 = User::Q()->getByAuth($u->email, $u->password)->limit(1)->exec();
        //objp($u2);
        $this->assertEquals($u2->email, $u->email);
        $updated_count = User::Q()->deleteAll(array('first_name = %s', $first_name));
        $this->assertEquals($updated_count, 1);
    }
Exemple #23
0
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 * @filesource
 */
Pfw_Loader::loadClass('Pfw_Exception_User');
/**
 * Short description for file
 *
 * Long description for file (if any)...
 * 
 * @category      Framework
 * @package       Pfw
 */
class Pfw_Exception_NotFound extends Pfw_Exception_User
{
    const ROUTE_MISSING_CONTROLLER = 0;
    const ROUTE_MISSING_ACTION = 1;
}
<?php

ini_set('post_max_size', "11M");
ini_set('upload_max_filesize', "11M");
Pfw_Loader::loadClass('Prj_Controller_Standard');
Pfw_Loader::loadClass('Prj_Components_FileUploaderComponent');
Pfw_Loader::loadModel('Project');
class ProjectController extends Prj_Controller_Standard
{
    public function __construct()
    {
        parent::__construct();
        // do any view initialization in here
        error_log(">>>IN PROJECT CONTROLLER[" . __CLASS__ . "]");
        $view = $this->getView();
        $view->addCssLink('custom-theme/jquery-ui-1.8.10.custom.css');
        $view->addJsLink('jquery-1.4.4.min.js');
        $view->addJsLink('jquery.dataTables.min.js');
        #$view->addJsLink('jquery.simplemodal-1.3.4.min.js');
        //$view->addCssLink('jquery.fileupload-ui.css');
        //$view->addJsLink('jquery.fileupload.js');
        //$view->addJsLink('jquery.fileupload-ui.js');
        $view->addJsLink('jquery.jqUploader.js');
        $view->addJsLink('jquery.flash.js');
        $view->addJsLink('custom-theme/jquery-ui-1.8.10.custom.min.js');
        #$view->addJsLink('custom-theme/jquery-ui-form.custom.min.js');
    }
    function indexAction()
    {
        $view = $this->getView();
        $view->assign('site_title', 'CalPalyn: Quaternary Paleoecology Lab Project Listing Page');
Exemple #25
0
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 * @filesource
 */
Pfw_Loader::loadClass('Pfw_Exception_Script');
Pfw_Loader::loadClass('Pfw_Script_FileSystem');
Pfw_Loader::loadClass('Pfw_Db_Migrate');
/**
 * Short description for file
 *
 * Long description for file (if any)...
 * 
 * @category      Framework
 * @package       Pfw
 */
class Pfw_Script_Migration
{
    protected $migration_file;
    public function __construct($migration_file, $dry_run = false)
    {
        if (true == $dry_run) {
            Pfw_Db_Migrate::$_dry_run = true;
        }
Exemple #26
0
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 * @filesource
 */
Pfw_Loader::loadClass('Pfw_Db_Select');
/**
 * Short description for file
 *
 * Long description for file (if any)...
 * 
 * @category      Framework
 * @package       Pfw
 */
class Pfw_Db_Select_Mysqli extends Pfw_Db_Select
{
}
Exemple #27
0
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2010 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 * @filesource
 */
Pfw_Loader::loadClass('Pfw_Controller_Mapper_Base');
Pfw_Loader::loadClass('Pfw_Exception_Dispatch');
/**
 * Default implementation of controller mapper. Maps a route to a 
 * Controller class and Action method.
 * 
 * @category      Framework
 * @package       Pfw
 */
class Pfw_Controller_Mapper_Standard extends Pfw_Controller_Mapper_Base
{
    const ACTION_SUFFIX = 'Action';
    private $valid_seps = array('-', '_', '.');
    // yes, yes, could be a regex, but this should be faster
    private $alpha = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
    private $numeric = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
    protected $map = array();
    /**
     * Maps controller and action names to a concrete class and action,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @category      Framework
 * @package       Pfw
 * @author        Sean Sitter <*****@*****.**>
 * @copyright     2008 The Picnic PHP Framework
 * @license       http://www.apache.org/licenses/LICENSE-2.0
 * @link          http://www.picnicphp.com
 * @since         0.10
 */
require '../../Pfw/UnitTest/PHPUnit/FwkTestCase.php';
Pfw_Loader::loadClass('Pfw_Controller_Router_Standard');
Pfw_Loader::loadClass('Pfw_Config');
Pfw_Loader::loadClass('Pfw_Cache_Local');
class Pfw_Cache_Local_Test extends Pfw_UnitTest_PHPUnit_FwkTestCase
{
    public function setup()
    {
        Pfw_Config::setConfig(array('local_cache' => 'Pfw_Cache_Stub'));
    }
    public function tearDown()
    {
        Pfw_Cache_Local::_reset();
    }
    public function testSetGet()
    {
        Pfw_Cache_Local::set('test', 'ok');
        $this->assertEquals('ok', Pfw_Cache_Local::get('test'));
    }
Exemple #29
0
<?php

ini_set('post_max_size', "11M");
ini_set('upload_max_filesize', "11M");
Pfw_Loader::loadClass('Prj_Controller_Standard');
Pfw_Loader::loadModel('Project');
class HomeController extends Prj_Controller_Standard
{
    public function __construct()
    {
        parent::__construct();
        // do any view initialization in here
        $view = $this->getView();
        $view->addCssLink('custom-theme/jquery-ui-1.8.10.custom.css');
        $view->addCssLink('fileuploader.css');
        $view->addJsLink('jquery-1.4.4.min.js');
        $view->addJsLink('jquery.dataTables.min.js');
        $view->addJsLink('highcharts.js');
        $view->addJsLink('exporting.js');
        //$view->addJsLink('jquery.jqUploader.js');
        //$view->addJsLink('jquery.flash.js');
        $view->addJsLink('fileuploader.js');
        #$view->addJsLink('jquery.simplemodal-1.3.4.min.js');
        $view->addJsLink('custom-theme/jquery-ui-1.8.10.custom.min.js');
        #$view->addJsLink('custom-theme/jquery-ui-form.custom.min.js');
    }
    function indexAction()
    {
        $view = $this->getView();
        $view->assign('home', true);
        $view->assign('site_title', 'CalPalyn: Quaternary Paleoecology Lab');
Exemple #30
0
<?php

/**
 * Add a project specific startup here
 */
global $_PATHS, $_ENVIRONMENT;
Pfw_Loader::loadFile("pfw_routes.php", $_PATHS['conf']);
Pfw_Loader::loadClass('Pfw_Controller_Front');
Pfw_Loader::loadClass('Pfw_PluginManager');
Pfw_Loader::loadClass('Pfw_Session');
Pfw_Loader::loadClass('Pfw_Alert');
// initialize the session
Pfw_Session::start();
// initialize the plugin manager
Pfw_PluginManager::init();
// initialize alerts
Pfw_Alert::init();
// turn off error display for production
if ($_ENVIRONMENT == "production") {
    ini_set('display_errors', 0);
    ini_set('log_errors', 1);
}
// setup front controller and routing
$front = Pfw_Controller_Front::getInstance();
$front->getRouter()->setRoutes($_pfw_routes)->setModules($_pfw_modules);
$four_oh_four = false;
try {
    $front->dispatch();
} catch (Pfw_Exception_System $e) {
    $e->emitLog();
    if ($_ENVIRONMENT == "development") {