/** * Loads and include jQuery js file from google's CDN * @param mixed $args must contain a 'tpl' key with the current template object */ public static function load($args) { if (!isset($args['tpl']) || $args['tpl'] == null) { throw new Core\Exception('Plugin Disqus needs a template object as argument in $args["tpl"]', E_USER_ERROR, self::CLASS_NAME); } if (!isset($args['id']) || $args['id'] == null) { throw new Core\Exception('Plugin Disqus needs a page identifier as argument in $args["id"]', E_USER_WARNING, self::CLASS_NAME); } $shortname = $args['shortname'] == null ? \Orion::config()->get('DISQUS_SHORTNAME') : $args['shortname']; $dev = $args['dev'] == true ? "var disqus_developer = 1;" : ""; if ($shortname == null) { throw new Core\Exception('Plugin Disqus needs a shortname string as argument in $args["shortname"] or in configuration under ["DISQUS_SHORTNAME"].', E_USER_ERROR, self::CLASS_NAME); } self::$TPL =& $args['tpl']; $script = '<script type="text/javascript"> //<![CDATA[ var disqus_shortname = "' . $shortname . '"; var disqus_identifier = "' . $args['id'] . '"; var disqus_url = "' . $args['permalink'] . '"; ' . $dev . ' //]]> </script> <script type="text/javascript" src="http://' . $shortname . '.disqus.com/embed.js" async></script>'; self::$TPL->addJs($script); self::$TPL->assign('disqus_message', '<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>'); }
/** * (Factory) Create and return a new Query instance based on Query\Base and specific to the DB type set in configuration. * @param String $class Name of the model class from whom the Factory call originates (Facultative). * @return \Orion\Core\Query\Base */ public static final function Factory($class = null) { if (!\Orion::config()->get('DB_TYPE')) { throw new Exception('No database type set in Orion configuration file.', E_ERROR, get_class()); } try { $queryClass = '\\Orion\\Core\\Query\\' . ucfirst(strtolower(\Orion::config()->get('DB_TYPE'))); return new $queryClass($class); } catch (Exception $e) { throw new Exception('Unable to load Query class for [' . \Orion::config()->get('DB_TYPE') . '] database type.', E_ERROR, get_class()); } }
/** * Manually close the connection to database * @return boolean success */ public static function disconnect() { if (!\Orion::config()->get('DB_TYPE')) { throw new Exception('No database type set in Orion configuration file.', E_ERROR, get_class()); } try { $dbClass = 'DB\\' . ucfirst(strtolower(\Orion::config()->get('DB_TYPE'))); return $dbClass::disconnect(); } catch (\Exception $e) { throw new Exception('Unable to load DB class for [' . \Orion::config()->get('DB_TYPE') . '] database type.', E_ERROR, get_class()); } }
/** * Loads a new SyntaxHighlighter plugin from Alex Gorbatchev's public CDN * No args required * @param mixed $args */ public static function load() { try { $theme = \Orion::config()->defined('SYNTAXHIGHLIGHTER_THEME') ? \Orion::config()->get('SYNTAXHIGHLIGHTER_THEME') : self::SH_THEME; Plugins\jQuery::loadPlugin(self::SH_DIR . 'scripts/shCore.js', true); Plugins\jQuery::loadPlugin(self::SH_DIR . 'scripts/shAutoloader.js', true); Plugins\jQuery::loadCSS($theme, true); Plugins\jQuery::script("\n function path()\n {\n var args = arguments,\n result = []\n ;\n \n for(var i = 0; i < args.length; i++)\n result.push(args[i].replace('@', '" . self::SH_DIR . "scripts/'));\n \n return result\n };\n \n SyntaxHighlighter.defaults['toolbar'] = false;\n\n SyntaxHighlighter.autoloader.apply(null, path(\n 'applescript @shBrushAppleScript.js',\n 'actionscript3 as3 @shBrushAS3.js',\n 'bash shell @shBrushBash.js',\n 'coldfusion cf @shBrushColdFusion.js',\n 'cpp c @shBrushCpp.js',\n 'c# c-sharp csharp @shBrushCSharp.js',\n 'css @shBrushCss.js',\n 'delphi pascal @shBrushDelphi.js',\n 'diff patch pas @shBrushDiff.js',\n 'erl erlang @shBrushErlang.js',\n 'groovy @shBrushGroovy.js',\n 'java @shBrushJava.js',\n 'jfx javafx @shBrushJavaFX.js',\n 'js jscript javascript @shBrushJScript.js',\n 'perl pl @shBrushPerl.js',\n 'php @shBrushPhp.js',\n 'text plain @shBrushPlain.js',\n 'py python @shBrushPython.js',\n 'ruby rails ror rb @shBrushRuby.js',\n 'sass scss @shBrushSass.js',\n 'scala @shBrushScala.js',\n 'sql @shBrushSql.js',\n 'vb vbnet @shBrushVb.js',\n 'xml xhtml xslt html @shBrushXml.js'\n ));\n SyntaxHighlighter.all();", true); } catch (Core\Exception $e) { throw $e; } }
/** * Check if user level is ($atleast) $slug * @param string $slug The level's slug * @param boolean $atleast Is exactly $slug (FALSE), or at least $slug (TRUE) */ public function is($slug, $atleast = false) { if (empty($this->level)) { throw new Core\Exception("Le niveau de l'utilisateur n'est pas défini."); } $roles = \Orion::config()->get('AUTH_ROLES'); if (!array_key_exists($slug, $roles)) { throw new Core\Exception("Le rôle demandé n'existe pas."); } $roleval = $roles[$slug]; if ($this->level == $roleval || $atleast && $this->level <= $roleval) { return true; } else { return false; } }
public function _login() { try { Core\Auth::login(); if (isset($_SESSION['orion_auth_target']) && $_SESSION['orion_auth_target'] != Core\Context::genModuleURL($this->name)) { $target = $_SESSION['orion_auth_target']; unset($_SESSION['orion_auth_target']); Core\Context::redirect($target); } else { Core\Context::redirect(Core\Context::genURL(\Orion::config()->get('DEFAULT_LOGGED_PAGE'))); } } catch (Core\Exception $e) { $this->assign('info', $e->getMessage()); $this->assign('type', 'error'); } $this->renderView('views/login'); }
/** * Main module function, executed right after module loading by Orion. * Handles route parsing and function callbacks. */ public function load() { if ($this->route == null) { if (!\Orion::config()->defined('ROUTING_AUTO') || \Orion::config()->get('ROUTING_AUTO') == false) { $this->sendError(self::E_ROUTE_NO); } $this->route = new Route(); $function = $this->route->decodeAuto(); } else { $function = $this->route->decode(); } if (Core\Tools::startWith($function->getName(), '__')) { $this->sendError(self::E_FUNCTION_NO); } if (Core\Tools::startWith($function->getName(), self::FUNCTION_PREFIX)) { $this->sendError(self::E_FUNCTION_NO); } if (!is_callable(array($this, self::FUNCTION_PREFIX . $function->getName()))) { $this->sendError(self::E_FUNCTION_NO); } Core\Tools::callClassMethod($this, self::FUNCTION_PREFIX . $function->getName(), $function->getArgs()); }
/** * Main module function, executed right after module loading by Orion. * Handles route parsing and function callbacks. */ public function load() { if ($this->route == null) { if (!\Orion::config()->defined('ROUTING_AUTO') || \Orion::config()->get('ROUTING_AUTO') == false) { throw new Exception('No route object found in controller and automatic routing is disabled.', E_USER_ERROR, get_class($this)); } $this->route = new Route(); $function = $this->route->decodeAuto(); } else { $function = $this->route->decode(); } if (Tools::startWith($function->getName(), '__')) { throw new Exception('Trying to access a resticted function, you are not allowed to use methods starting with "__".', E_USER_ERROR, get_class($this)); } if (Tools::startWith($function->getName(), self::FUNCTION_PREFIX)) { throw new Exception('Function name in rule must be declared without function prefix ' . self::FUNCTION_PREFIX . '.', E_USER_ERROR, get_class($this)); } if (!is_callable(array($this, self::FUNCTION_PREFIX . $function->getName()))) { Context::redirect(404); } Tools::callClassMethod($this, self::FUNCTION_PREFIX . $function->getName(), $function->getArgs()); }
/** * Return PDO instance or create intitial connection * @return PDO * @access public */ public static function getConnection() { if (!self::$instance) { try { $config = \Orion::config(); if (in_array($config->get('SQL_DRIVER'), self::$SQL_DRIVERS)) { $driver = $config->get('SQL_DRIVER'); } else { $driver = self::$DEFAULT_DRIVER; } if ($config->defined('SQL_PORT')) { $port = ';port=' . $config->get('SQL_PORT'); } else { $port = ''; } self::$instance = new \PDO($driver . ":host=" . $config->get('SQL_HOST') . $port . ";dbname=" . $config->get('SQL_DBNAME'), $config->get('SQL_USER'), $config->get('SQL_PASSWORD')); self::$instance->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); } catch (\PDOException $e) { throw new Exception($e->getMessage(), $e->getCode(), get_class()); } } return self::$instance; }
/** * An elaborated split/double-salted hash method to hash passwords for example. * Uses sha1 as final hashing algorithm * @param string $data * @param string $extrasalt * @return hash */ public static function saltedHash($data, $extrasalt) { $password = str_split($data, strlen($data) / 2 + 1); $hash = hash('sha1', $extrasalt . $password[0] . \Orion::config()->get('SECURITY_KEY') . $password[1]); return $hash; }
/** * Decode current request URI into a usable OrionRouteMethod using an automated parser.<br /> * It's then possible to retreive the method to call and the arguments via the following getters:<br /> * OrionRouteMethod->getMethod();<br /> * OrionRouteMethod->getArgs();<br /> * OrionRouteMethod->getURI();<br /> * * @return OrionRouteMethod * @see OrionRouteMethod */ public function decodeAuto() { $uri = Context::$MODULE_URI; $matches = array(); if ($uri == '' || $uri == '/') { return new RouteMethod($this->defaultMethod, null, $uri); } if (preg_match('/^([a-zA-Z0-9_-]+)\\/(.*)$/i', $uri, $matches)) { array_shift($matches); $method = array_shift($matches); $args = array_shift($matches); if (\Orion::config()->defined('ROUTE_AUTO_ARGSEP')) { $cargs = explode(\Orion::config()->get('ROUTE_AUTO_ARGSEP'), $args); } else { $cargs = array($args); } return new RouteMethod($method, $cargs, $uri); } elseif (preg_match('/^([a-zA-Z0-9_-]+)$/i', $uri, $matches)) { array_shift($matches); $method = array_shift($matches); return new RouteMethod($method, null, $uri); } return new RouteMethod($this->errorMethod, array(self::E_NORULE), $uri); }
/** * * @param String $directory The relative path to the directory to empty. (relative to the upload directory) * @param boolean $empty Set this to TRUE to only empty the directory, FALSE|NULL to empty AND remove the directory * @return boolean */ public static function deleteDir($directory, $empty = false) { if (!\Orion::config()->defined('UPLOAD_DIR')) { throw new Exception('UPLOAD_DIR is not defined in Orion configuration.', E_ERROR, get_class()); } $base = $directory; $directory = \Orion::config()->get('UPLOAD_DIR') . $directory; if (substr($directory, -1) == DS) { $directory = substr($directory, 0, -1); } if (!file_exists($directory) || !is_dir($directory)) { return false; } elseif (!is_readable($directory)) { return false; } else { $directoryHandle = opendir($directory); while ($contents = readdir($directoryHandle)) { if ($contents != '.' && $contents != '..') { $path = $directory . "/" . $contents; if (is_dir($path)) { self::deleteDir($base . "/" . $contents); } else { unlink($path); } } } closedir($directoryHandle); if ($empty == false) { if (!rmdir($directory)) { return false; } } return true; } }
public static function debug() { self::$DEBUG = true; }
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.</p> * * * @author Thibaut Despoulain * @copyright 2010-2012, Thibaut Despoulain * @link http://orionphp.org/ * @version 0.11.12 beta1 */ session_start(); error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); //error_reporting(-1); require_once 'orion/orion.php'; try { $orion = new Orion('orion/'); $orion->configure('main'); //$orion->debug(); $orion->run(); } catch (Exception $e) { $html = "<!DOCTYPE html><html lang=en><head><meta charset=utf-8><title>Oops, something wrong happened</title><style>*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKsAAADVCAMAAAAfHvCaAAAAGFBMVEVYn%2BH%2F%2F%2F%2Bex%2B3U5vd7s%2Bfq8%2Fs0itq72PMLUPvtAAASvklEQVR4AbXBC0JqCQxEwT5Jd7L%2FHc8FdR4g%2BEGtEr8u%2FBHxu7otdzd%2FQPyqlmRp1Pw%2B8aukDfRa1fw28ZtWy4sa89vEb7LCi0zx28RvqgkvouW3id%2FU8pbtWmv5beJXRWNrRmp%2BnfhlHXZm%2BQPi95Vk%2FoD4fZbMHxC%2FryTzB8Tva435A%2BL3rcb8AfH7VjJ%2FQPy%2BHYk%2FIH5facwfEL8iaZcrnKyn%2BAPi57K2VL2WF1hJ%2FAHxQ2tJrg6HteXVjPkD4ge6V3J1%2BF97zhx%2BnXhWb8nacKXlnYPErxNPyfqw4ZYKVuUZdfhd4hmxunY73NICgfWMOvwm8ZQ1pMvlDZdaCic98kjV4beIp8ScpLvsSvhflzqQmqVLB281v0E8pc2bdNne8EayNTPNSbt02PBj4intcKltb%2FNibY%2BLf9aSO%2FyMeMo6XMva3g0vwrWsxvyMeEoc3knZ2g53ZaXa8DzxlHa4J23Jae5aycXTxFPa4WRdXAtdsivckZXG4TniKWtOSlre6y7LG651Wxq5OzxDPGUVIKNwX6ekC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FXKpzUONxKFWo%2BJt5J0ltlzQxfsCqimSpv86KmrHApBbXA2s2NuKPwMfFQvOELWgvsnEjVQMYtc2UXqjm0xI0yq%2FAx8T0JtyJz8DiekWpjxWoupRqqOamp5VJPsXJt9256wz3iW8oOt1xNaWah3NZJZK7UAg6HLo%2B5tFPgke2SreUe8R1rO9xayTpALFaa2Z3mUhyo4qQ6I67MbLlsyyfFPeI71m7ey0orw2pL256WuFILVHOI41mu1IyK3u0q28094nvCXQHLtqyF9Gq5tA7E4bAViRsrNW%2FCXeK3lDTVVoBI4ZIDVHFYpbTcyIbPiF%2FTSbPT3SUtl6qAuDl4W8UzxC%2Fz6CRciALUcijT4inil%2FV2p4pLtUDcwCol8xTxF8KlKg5VQGtb4jniz7UbWAcox%2BJJ4s%2B5OLiAVnuKJ4m%2FtuawBURbszxL%2FLF4OXgh9s7yNPHHqjisgVLLPE%2F8rXYD7UCrVsXzxN%2Bq4uAGrFj8gPhTXRzKwGprmh8Qf2rlot2AvSp%2BQvyl1nikAlprh58Qf0lqolGBarX8iPhLZWBVqnVsfkb8pTaHcru61PyM%2BEtrDq2UW8sPib%2FUChBvbIcfEn%2FKxWGrpeWnxJ9qVYDyVPgp8bfa2qRmmh8Tf21lq5qfE38uveE3%2FAdr385%2FSVd%2FMAAAAABJRU5ErkJggg%3D%3D) 100% 5px no-repeat;margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{padding-right:205px}p{margin:22px 0 0;overflow:hidden}ins,#g{text-decoration:none}ins{color:#777}a img{border:0}#g{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAAA3CAMAAADZn0ObAAABgFBMVEX%2F%2F%2F%2Fy1pHuLjfMm2W4yfA1TrPukgZDats3V8fwTEypjWy8u7oPsSWVsOoBdwwClhI%2FZdlasGjpOUOVlJjx0c20CyZpea36pAdIdebyu7COlqpYaql2hLH40Gn59vayuMlZiOunpqjYGy9wiNLd5PRqlOzzcmz%2Fwi4FpRrqsD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2HoLpQkACv3n8FCLiqDE3tM%2BKPO1%2B8UIhjXxxdeWj6Rr09UNB9RROELM5hsmKLHf962VWWFkRRSFfVo0B522KCtGxer1Ov8DileJKq%2BZYTvnp38mxYpaBEIXbjvasyMRot3vmCE5ONA2TBhwOytcP1kiJrxyZ1e82CMrnCEAeURB5NwmWT%2F7NvIkQ%2BPffnicQmxdEMZuFVcNxBX3byR5QSfv4nMbhLYpEH%2BAifeI3vCYYx%2FuQ6IIXUDGDSqE8dBPTDMP9YzTjjDToinSoa4aEDRDtSC87vl8Y2xXCRGtKhuLA1j3DssPJRYppHcxOmvbvGxb4OqllSxeH4Y1B9woriseSDV4Nolgh92Pi%2FcLSKZPpa%2FWwFCdnHDx3v6h07GdoOFJlLq1TbEs3HyJn6PG%2FTf%2FH9ie6cY%2BViJA9lUqdQ7f2Be4fFfap2IzSYLG7k1c%2BGDp%2BAFTKJF%2FzufdnZtz7PrrevDZ03GPAaJDjbRA8dGsW6X6cgNmAhSEG%2FUiY%2Fsfiv02O7iVu1LunAAAAAElFTkSuQmCC);display:block;height:55px;margin:0 0 -7px;width:150px}* > #g{margin-left:-2px}#g img{visibility:hidden}* html #g img{visibility:visible}*+html #g img{visibility:visible}</style></head>\n <body><p><b>Exception found !</b><br><ins>But it's OK, no kittens were harmed in the process.</ins>\n <p>" . $e->__toString() . "</p><p><ins>That's all we know.</ins></p>"; if (\Orion::isDebug()) { $html .= "<h3>Traceback</h3><p>" . nl2br($e->getTraceAsString()) . "</p>"; } $html .= "</body></html>"; die($html); exit(1); }
/** * <p><b>Must be called AFTER Core\Auth::login()</b></p> * Allows access only to logged users that have a level equal to or less than provided role. If permission is nsot granted, it will automatically redirect the user to the login module. * <p><b>Note that while it's doing all login/auth/redirection work automatically, you still have to create the corresponding user table in your database in addition to provide the login module into orion's module directory.</b></p> * @see Core\Auth * MainConfig * LoginModule * @param string $slug the role identifier (ie: 'administrator', 'member', etc.). See your configuration file for a liste of roles and their permission level. * @return bool TRUE if user has the permission, FALSE otherwise (even if redirected) */ public static function allow($slug, $noredirect = false) { if (!self::logged()) { self::login(); } $roles = \Orion::config()->get('AUTH_ROLES'); if (!array_key_exists($slug, $roles)) { throw new Exception('Unable to restrict access, role [' . $slug . '] does not exist.', E_USER_ERROR, __CLASS__); } if (self::$user == null || empty(self::$user->level) || self::$user->level <= 0) { throw new Exception('Missing user information. See Core\\Auth for more info.', E_USER_ERROR, __CLASS__); } if (self::$user->level > $roles[$slug]) { Context::setHeaderCode(403); if (!$noredirect) { Context::redirect(Context::genModuleURL('users', 'error-' . self::E_LEVEL_RESTRICT, 'default')); } return false; } else { return true; } }
/** * Get the full path to the provided template folder * @param string $template Template name * @return string */ public static function getTemplateAbsolutePath($template) { return \Orion::config()->get('TEMPLATE_ABS_PATH') . $template . DS; }
/** * Get current query string * @return string current query string */ public function getQuery() { if ($this->_TABLE == null) { throw new Core\Exception('Unable to perform query, no table provided.'); } if ($this->hasModel()) { $this->unsetTable(); } if ($this->_MWHERE != null) { $where = $this->_MWHERE; } else { if (!empty($this->_WHERE) && is_array($this->_WHERE)) { $where = implode(' ', $this->_WHERE); if (!empty($this->_AWHERE)) { foreach ($this->_AWHERE as $andClause) { $where .= ' AND ' . implode(' ', $andClause); } } if (!empty($this->_OWHERE)) { foreach ($this->_OWHERE as $orClause) { $where .= ' OR ' . implode(' ', $orClause); } } } else { $where = null; } } switch ($this->_TYPE) { case 'select': $query = "SELECT "; if ($this->_DISTINCT) { $query .= 'DISTINCT '; } $query .= implode(', ', $this->_COLUMNS); foreach ($this->_JOIN_COLUMNS as $col) { $query .= ", " . implode(' AS ', $col); } $query .= " FROM " . $this->antiQuote($this->_TABLE); if (!empty($this->_JOIN)) { if (!$this->hasModel()) { throw new Core\Exception('Trying to execute a join query with no model bound.'); } else { $model = $this->model; } } foreach ($this->_JOIN as $key => $data) { $query .= " " . strtoupper($data[1]) . " JOIN " . $this->antiQuote($data[0]) . " ON " . $this->tablePrefix($model::getField($key)->getBinding()) . "=" . $this->tablePrefix($model::getField($key)->getRightfield(), false, $data[0]); } foreach ($this->_JOIN_TABLE as $table => $data) { $query .= " " . strtoupper($data[2]) . " JOIN " . $this->antiQuote($table) . " ON " . $this->tablePrefix($data[0]) . "=" . $this->tablePrefix($data[1], false, $table); } if ($where != null) { $query .= " WHERE " . $where; } if ($this->_GROUPBY != null) { $query .= " GROUP BY " . $this->_GROUPBY; } if (!empty($this->_ORDER)) { $order = array(); foreach ($this->_ORDER as $field => $mode) { $order[] = $field . ' ' . $mode; } $query .= " ORDER BY " . implode(', ', $order); } if ($this->_LIMIT != null) { $query .= " LIMIT " . $this->_LIMIT; } if ($this->_OFFSET != null) { $query .= " OFFSET " . $this->_OFFSET; } break; case 'insert': if (empty($this->_DATA)) { throw new Core\Exception('Missing row data in insert query.'); } $query = "INSERT INTO `" . $this->_TABLE . "`"; $keys = array_keys($this->_DATA); $values = array_values($this->_DATA); $query .= " (" . implode(', ', $keys) . ") VALUES (" . implode(', ', $values) . ")"; break; case 'update': if (empty($this->_DATA)) { throw new Core\Exception('Missing row data in update query.'); } $query = "UPDATE `" . $this->_TABLE . "`"; $sets = array(); foreach ($this->_DATA as $key => $value) { $sets[] = $key . '=' . $value; } $query .= " SET " . implode(', ', $sets); if ($where == null) { throw new Core\Exception('Update query must have a where clause.'); } else { $query .= " WHERE " . $where; } if ($this->_LIMIT != null) { $query .= " LIMIT " . $this->_LIMIT; } break; case 'delete': $query = "DELETE FROM `" . $this->_TABLE . "`"; if ($where == null) { throw new Core\Exception('Delete query must have a where clause.', E_USER_WARNING, get_class($this)); } else { $query .= " WHERE " . $where; } if ($this->_LIMIT != null) { $query .= " LIMIT " . $this->_LIMIT; } break; default: throw new Core\Exception('Unknown query type.', E_USER_WARNING, get_class($this)); break; } $this->_QUERY_STRING = $query; if (\Orion::isDebug()) { echo 'SQL_QUERY: ' . $query . '<br />'; } return $query . ';'; }
/** * Get important context data as an array (useful for template hydratation) */ public function getDataArray() { $array = array(); try { $array['module'] = array(); $array['module']['name'] = \Orion::module()->getName(); $array['module']['path'] = \Orion\Core\Context::getModulePath(); $array['module']['url'] = \Orion\Core\Context::getModuleURL(\Orion::module()->getName()); $array['module']['uri'] = \Orion\Core\Context::getModuleURI(); $array['module']['fulluri'] = \Orion\Core\Context::getFullURI(); $array['template'] = array(); $array['template']['name'] = \Orion::module()->getTemplate(); $array['template']['path'] = \Orion\Core\Context::getTemplatePath(\Orion::module()->getTemplate()); $array['template']['abspath'] = \Orion\Core\Context::getTemplateAbsolutePath(\Orion::module()->getTemplate()); if (\Orion::config()->defined(strtoupper(\Orion::getMode()) . '_MENU')) { $array['menu'] = \Orion::config()->get(strtoupper(\Orion::getMode()) . '_MENU'); } $array['title'] = \Orion::config()->get('SITE_NAME'); $array['description'] = \Orion::config()->get('SITE_DESC'); $array['author'] = \Orion::config()->get('SITE_AUTHOR'); $array['baseurl'] = \Orion::config()->get('BASE_URL'); $array['mode'] = \Orion::getMode(); $array['logged'] = \Orion\Core\Auth::logged() ? 'yes' : 'no'; if (\Orion\Core\Auth::user() != null) { $array['user'] = array(); $array['user']['login'] = \Orion\Core\Auth::user()->login; $array['user']['hasadmin'] = \Orion\Core\Auth::user()->is('moderator', true); } } catch (Exception $e) { $array['error'] = 'Unable to retreive all data.'; } return $array; }