public function testServe() { $routes = Erdiko::getRoutes(); $_SERVER['REQUEST_METHOD'] = 'get'; ob_start(); Toro::serve($routes); $out = ob_get_contents(); ob_end_clean(); //echo "Printing buffer............."; //var_dump($out); //Remove header $pos = strrpos($out, "</header>"); $out = substr($out, $pos + 9); //Remove footer $pos = strrpos($out, '<footer id="footer">'); $out = substr($out, 0, $pos); //var_dump($out); /* $header = file_get_contents($themeFolder.'/templates/page/header.php'); $pos = strrpos($header, 'navbar-brand'); $header = substr($header, 0, $pos); $find = strrpos($return, $header); $this->assertTrue($find != false); */ }
function setUp() { // create a new instance of String with the // string 'abc' $this->cacheObj = Erdiko::getCache("default"); //$this->cacheObj = new Cache(); }
/** * Constructor */ public function __construct() { // Connection creation $this->memcacheObj = new \Memcached(); $config = \Erdiko::getConfig("local/cache"); $host = $config["memcached"]["host"]; $port = $config["memcached"]["port"]; $cacheAvailable = $this->memcacheObj->addServer($host, $port); }
public function __construct($shop_domain, $token, $api_key, $secret) { $this->name = "ShopifyClient"; $this->shop_domain = $shop_domain; $this->token = $token; $this->api_key = $api_key; $this->secret = $secret; \Erdiko::log(null, "{$shop_domain}, {$token}, {$api_key}, {$secret}"); }
/** * Get the cache instance * * @param string $cacheConfig * @return object */ public static function getCacheObject($cacheConfig = 'default') { //Check if the caller requests an new object if (empty(self::$instance[$cacheConfig])) { $config = \Erdiko::getConfig('application/default'); //Check if the object already be created if (isset($config["cache"][$cacheConfig])) { self::$instance[$cacheConfig] = new $config["cache"][$cacheConfig]['class'](); } else { throw new \Exception("There is no cache config defined ({$cacheConfig})"); } } return self::$instance[$cacheConfig]; }
public static function getCache($cacheType = null) { $config = Erdiko::getConfig("contexts/default"); if (!isset($cacheType)) { $cacheType = "default"; } if (isset($config["cache"][$cacheType])) { $cacheConfig = $config["cache"][$cacheType]; $class = "erdiko\\core\\cache\\" . $cacheConfig["type"]; return new $class(); } else { return false; } }
/** * Get the API Scope * * @return string **/ private function returnScope() { $config = \Erdiko::getConfig('local/shopify'); return $config['appInfo']['SHOPIFY_SCOPE']; }
<?php echo Erdiko::getView(2, 'd3/map-nav.php'); ?> <h3>Map with tooltips</h3> <div id="map"></div> <script> var m_width = $("#map").width(), width = 938, height = 500, country, state; var projection = d3.geo.mercator() .scale(150) .translate([width / 2, height / 1.5]); var path = d3.geo.path() .projection(projection); var svg = d3.select("#map").append("svg") .attr("preserveAspectRatio", "xMidYMid") .attr("viewBox", "0 0 " + width + " " + height) .attr("width", m_width) .attr("height", m_width * height / width); svg.append("rect") .attr("class", "background")
/** * Get About */ public function getAbout() { $this->setTitle("About"); $data = \Erdiko::getConfig("application", getenv('ERDIKO_CONTEXT')); $this->addView('examples/about', $data); }
<?php /** * Bootstrap Eloquent * * @category erdiko * @package eloquent * @copyright Copyright (c) 2016, Arroyo Labs, http://www.arroyolabs.com * @author John Arroyo, john@arroyolabs.com */ use Illuminate\Database\Capsule\Manager as Capsule; $capsule = new Capsule(); // Get db credentials from the database.json config $dbConfig = \Erdiko::getConfig('local/database'); $creds = $dbConfig['connections'][$dbConfig['default']]; $capsule->addConnection(array('driver' => $creds['driver'], 'host' => $creds['host'], 'database' => $creds['database'], 'username' => $creds['username'], 'password' => $creds['password'], 'charset' => $creds['charset'], 'collation' => $creds['collation'], 'prefix' => $creds['prefix'])); $capsule->bootEloquent();
$response = new \erdiko\core\Response($theme); $response->setContent(\Erdiko::getView('error', $vars)); $response->send(); }); ToroHook::add("500", function ($vars = array()) { // Toro::serve Legacy $vars['debug'] = \erdiko\core\ErrorHandler::isDebug(); $vars['code'] = 500; $vars['message'] = "Sorry, something went wrong."; Erdiko::log(\Psr\Log\LogLevel::ERROR, "{$vars['code']}: {$vars['path_info']} {$vars['error']}"); $theme = new \erdiko\core\Theme('bootstrap'); $theme->addCss('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css'); $theme->addCss('font-awesome-animation', '/themes/bootstrap/css/font-awesome-animation.css'); $response = new \erdiko\core\Response($theme); $response->setContent(\Erdiko::getView('error', $vars)); $response->send(); }); // Error management & beautify output. ToroHook::add("general_error", function ($vars = array()) { $vars['debug'] = \erdiko\core\ErrorHandler::isDebug(); if (!isset($vars['path_info'])) { $vars['path_info'] = $_SERVER['REQUEST_URI']; } Erdiko::log(\Psr\Log\LogLevel::ERROR, "{$vars['code']}: {$vars['path_info']} {$vars['error']}"); $theme = new \erdiko\core\Theme('bootstrap'); $theme->addCss('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css'); $theme->addCss('font-awesome-animation', '/themes/bootstrap/css/font-awesome-animation.css'); $response = new \erdiko\core\Response($theme); $response->setContent(\Erdiko::getView('error', $vars)); $response->send(); });
<?php /** * Index file * Intercepts all requests and dispatch routes * * @category Erdiko * @package Public * @copyright Copyright (c) 2016, Arroyo Labs, www.arroyolabs.com * @author John Arroyo */ // Bootstrap your app and erdiko include_once dirname(dirname(__DIR__)) . "/app/bootstrap.php"; try { $routes = Erdiko::getRoutes(getenv('ERDIKO_CONTEXT')); Toro::serve($routes); } catch (\Exception $e) { echo $e->getMessage(); // @todo return a 500 error & log error }
<div style="border: 2px solid; width: 550px; padding: 10px; margin-top: 29px; margin-left: 264px;"> <form name = "editStoreInfoForm" method ="get" action="/shop/editStoreInfo"> <table> <?php $data = $data->getData(); $keys = $data['keys']; $nonEmpty = count($keys); for ($i = 0; $i < count($keys); $i++) { $item = array('size' => count($data), 'details' => array('serial_num' => $i + 1, 'key' => $data['keys'][$i], 'value' => $data['values'][$data['keys'][$i]])); echo Erdiko::getView('shopify/grid/storeInfoFormInput', $item, $this->_viewRootFolder); } ?> <input type="hidden" name="num_val" value="<?php echo count($keys); ?> "/> <tr> <td></td> <td> <input type = "submit" value = "Edit" style="width: 70px;"> </input> </td> </tr> </table> </form> </div>
<div class="container-fluid"> <div class="row"> <div role="main"> <?php $data = $data->getData(); //$blog_id=$_GET['blog_id']; $blog_id = $data[count($data) - 1]; array_pop($data); //echo Erdiko::getView('shopify/grid/addNewBlogMetaField',$blog_id,$this->_viewRootFolder); for ($i = 0; $i < count($data); $i++) { $item = array('size' => count($data), 'details' => array('serial_num' => $i + 1, 'title' => $data[$i]['title'], 'id' => $data[$i]['id'], 'content' => 'showArticleContent?blog_id=' . $blog_id . "&article_id=" . $data[$i]['id'], 'article_info' => 'showArticleInfo?blog_id=' . $blog_id . "&article_id=" . $data[$i]['id'])); if ($i == 0) { echo Erdiko::getView('shopify/grid/newsArticleHead', $item, $this->_viewRootFolder); } echo Erdiko::getView('shopify/grid/articleRow2', $item, $this->_viewRootFolder); } ?> </div> </div> </div>
<?php /** * Index file * Intercepts all requests and dispatches routing * * @category Erdiko * @package Public * @copyright Copyright (c) 2014, Arroyo Labs, www.arroyolabs.com * @author John Arroyo */ include_once dirname(__DIR__) . "/bootstrap.php"; try { $routes = Erdiko::getRoutes(); Toro::serve($routes); } catch (\Exception $e) { echo $e->getMessage(); // @todo return a 500 error & log error }
<div class="container-fluid"> <div class="row"> <div role="main"> <?php $data = $data->getData(); // temporary hack $item = array('size' => $data['columns'], 'details' => array('name' => "Example Item", 'image' => "http://placehold.it/180x180/BBBBBB/EEEEEE&text=Grid+Item", 'url' => "#")); for ($i = 0; $i < $data['count']; $i++) { echo Erdiko::getView('examples/grid/item', $item); } ?> </div> </div> </div>
<?php echo Erdiko::getView(3, 'd3/chart-nav.php'); ?> <h3>Includes X & Y Axis Labels</h3> <svg class="chart"></svg> <script> var width = 960, height = 500; var y = d3.scale.linear() .range([height, 0]); var chart = d3.select(".chart") .attr("width", width) .attr("height", height); d3.tsv("d3/barchart2-data.tsv", type, function(error, data) { y.domain([0, d3.max(data, function(d) { return d.value; })]); var barWidth = width / data.length; var bar = chart.selectAll("g") .data(data) .enter().append("g") .attr("transform", function(d, i) { return "translate(" + i * barWidth + ",0)"; });
<?php /** important: download zend and place in /www/libraries/Zend **/ // Register Zend autoloader require_once "Zend/Loader.php"; spl_autoload_register(array("Zend_Loader", "loadClass")); /** GET CONFIGS FROM json FILE ***/ $config = Erdiko::getConfig('local/database'); // Use the master settings for now $config = $config['master']; /* CREATE THE DB ADABPTER OUT OF CONFIGURATIONS */ $db = Zend_Db::factory($config['adapter'], $config['params']); /* @TODO: ATTACH THE PROFILER TO THE DB ADAPTER */ /* RUN BASIC QUERIES TO HAVE THE DATA ENTIRELY IN UNICODE */ //$db->query('SET NAMES utf8'); //$db->query('SET CHARACTER SET utf8'); /* SETUP A FIXED DATABASE ADAPTER FOR ALL MODELS THROUGHOUT THE ENTIRE APPLICATION */ Abstract_Table::setDefaultAdapter($db);
<div class="container-fluid"> <div class="row"> <div class="col-md-12" role="main"> <?php $title = $this->getPageTitle(); if (!empty($title)) { echo "<h1>" . $title . "</h1>\n"; } $data = $this->getLayoutData(); // @todo rename 'templates' folder to 'layouts' // error_log("data: ".print_r($data, true)); ?> </div> </div> <div class="row"> <div class="col-md-12" role="main"> <?php $item = array('size' => $data['columns'], 'details' => array('name' => "Example Item", 'image' => "http://placehold.it/180x180/BBBBBB/EEEEEE&text=Grid+Item", 'url' => "#")); for ($i = 0; $i < $data['count']; $i++) { echo Erdiko::getView($item, '/grid/item.php'); } ?> </div> </div> </div>
<div class="container-fluid"> <div class="row"> <div role="main"> <?php echo Erdiko::getView('shopify/grid/addNewKeyButton', null, $this->_viewRootFolder); $data = $data->getData(); if (count($data) > 0) { $keys = $data['keys']; for ($i = 0; $i < count($keys); $i++) { $item = array('size' => count($data), 'details' => array('serial_num' => $i + 1, 'key' => $data['keys'][$i], 'value' => $data['values'][$data['keys'][$i]], 'edit' => "showEditStoreMetafields?id=" . $data["id"][$data['keys'][$i] . '_id'] . "&key=" . $data['keys'][$i] . "&value=" . $data['values'][$data['keys'][$i]] . "&value_type=" . $data['value_type'][$data['keys'][$i]], 'delete' => "deleteStoreMetafields?id=" . $data["id"][$data['keys'][$i] . '_id'])); if ($i == 0) { echo Erdiko::getView('shopify/grid/tableHead', $item, $this->_viewRootFolder); } echo Erdiko::getView('shopify/grid/storeInfoRow', $item, $this->_viewRootFolder); } $newData['delete'] = $data['delete_link']; $newData['edit'] = $data['edit_link']; echo Erdiko::getView('shopify/grid/changeStoreInfo', $newData, $this->_viewRootFolder); } ?> </div> </div> </div>
<div class="container-fluid"> <div class="row"> <div role="main"> <?php $data = $data->getData(); // temporary hack for ($i = 0; $i < count($data); $i++) { $item = array('size' => count($data), 'details' => array('name' => $data[$i]['title'], 'image' => $data[$i]['image']['src'], 'url' => "#", 'product_id' => $data[$i]['id'])); //echo $this->_viewRootFolder; echo Erdiko::getView('shopify/grid/item', $item, $this->_viewRootFolder); } ?> </div> </div> </div>
/** * Get About */ public function getAbout() { $this->setTitle("About"); $data = \Erdiko::getConfig("application/default"); $this->setContent("<h2>{$data['site']['full_name']}</h2> <h3>{$data['site']['tagline']}</h3> <p>{$data['site']['description']}</p>"); }
/** * Hooks */ ToroHook::add("404", function ($vars = array()) { // error_log("vars: ".print_r($vars, true)); if (empty($vars['message'])) { $vars['message'] = "Sorry, we cannot find that page."; } if (empty($vars['error'])) { $vars['error'] = $vars['message']; } if (!isset($vars['path_info'])) { $vars['path_info'] = ""; } Erdiko::log(\Psr\Log\LogLevel::ERROR, "404 {$vars['path_info']} {$vars['error']}"); // For a simple text only 404 page use this... // echo "Sorry, we cannot find that URL"; // die; // don't let the calling controller continue // For a themed 404 page... $theme = new \erdiko\core\Theme('bootstrap'); $theme->addCss('//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css'); $theme->addCss('/themes/bootstrap/css/font-awesome-animation.css'); $response = new \erdiko\core\Response($theme); $response->setContent(\Erdiko::getView('404', $vars)); $response->send(); }); ToroHook::add("500", function ($vars = array()) { // error_log("vars: ".print_r($vars, true)); Erdiko::log(\Psr\Log\LogLevel::ERROR, "500 {$vars['path_info']} {$vars['error']}"); echo "Sorry, something went wrong"; });
public function getCache() { //Reture false if config file is not existed $this->assertTrue(Erdiko::getCache("default")); }