本文整理汇总了PHP中App::module方法的典型用法代码示例。如果您正苦于以下问题:PHP App::module方法的具体用法?PHP App::module怎么用?PHP App::module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::module方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
public function __invoke()
{
$client = new Google_Client();
$client->setDeveloperKey($_ENV["GOOGLE_API_CODE"]);
$album = App::module('album')->getSingle();
$youtube = new Google_Service_YouTube($client);
$videos = [];
// get the tracklist for the global post
$tracklist = json_decode($album->albumTracklist);
$favorites = $album->favorites;
$reviewTracks = App::module('song')->get(['meta_query' => [['key' => 'itunesCollectionId', 'value' => $album->itunesCollectionId]]]);
$temp = [];
foreach ($reviewTracks as $index => $value) {
$temp[$value->title] = $value;
}
$reviewTracks = $temp;
if ($favorites) {
$favorites = explode(",", $favorites);
}
if ($favorites === "") {
$favorites = [];
}
$searchResponse = [];
foreach ($favorites as $index => $favorite) {
$res = $youtube->search->listSearch('id,snippet', array('q' => str_replace(" ", "+", "{$album->artist}+{$favorite}"), 'maxResults' => 1));
if ($res) {
foreach ($res['items'] as $searchResult) {
$searchResponse[] = [$searchResult['id']['videoId'], $favorite];
}
}
}
$html = ["<div class='tab-group'>", "<div class='tab'>", "<div class='tab-label'><i class='fa fa-headphones'></i></div>", "<div class='tab-inner'>", "<h3>Previews</h3>", "<hr />"];
foreach ($searchResponse as $index => $id) {
$html[] = "<div class='embed-wrapper'><h4>{$id[1]}</h4><a href='#' data-video-id='{$id[0]}' data-video-name='{$id[1]}' class='youtube-link'><i class='fa fa-youtube'></i></a></div>";
}
$html[] = "</div></div><div class='tab'><div class='tab-label'><i class='fa fa-list-ol'></i></div><div class='tab-inner'><h3>Tracklist</h3><hr /><ul class='tracklist'>";
foreach ($tracklist as $index => $el) {
$strong = in_array($el->name, $favorites);
$hasSeparatePost = isset($reviewTracks[$el->name]);
$num = $index + 1;
if ($hasSeparatePost) {
$link = $reviewTracks[$el->name]->url;
$html[] = "<li><a href='{$link}' style='color:white;'><strong data-favorite-track='{$el->name}'>{$num}: {$el->name}</strong></a></li>";
} elseif ($strong) {
$html[] = "<li><strong data-favorite-track='{$el->name}'>{$num}: {$el->name}</strong></li>";
} else {
$html[] = "<li>{$num}: {$el->name}</li>";
}
}
$html = implode("", $html) . "</ul></div></div></div>";
return $html;
}
示例2: __invoke
public function __invoke()
{
$client = new Google_Client();
$client->setDeveloperKey($_ENV["GOOGLE_API_CODE"]);
$song = App::module('song')->getSingle();
$youtube = new Google_Service_YouTube($client);
$res = $youtube->search->listSearch('id,snippet', array('q' => str_replace(" ", "+", "{$song->artist}+{$song->title}"), 'maxResults' => 1));
$searchResponse = [];
if ($res) {
foreach ($res['items'] as $searchResult) {
$searchResponse = $searchResult['id']['videoId'];
}
}
$html = ["<div class='tab-group'>", "<div class='tab'>", "<div class='tab-label'><i class='fa fa-headphones'></i></div>", "<div class='tab-inner'>", "<h3>Previews</h3>", "<hr />"];
$html[] = "<div class='embed-wrapper'><h4>{$song->title}</h4><a href='#' data-video-id='{$searchResponse}' data-video-name='{$song->title}' class='youtube-link'><i class='fa fa-youtube'></i></a></div>";
$html[] = "</div></div>";
$html = implode("", $html) . "</div>";
return $html;
}
示例3: ucfirst
function __construct(&$a)
{
/**
*
* We have already parsed the server path into App::$argc and App::$argv
*
* App::$argv[0] is our module name. Let's call it 'foo'. We will load the
* Zotlabs/Module/Foo.php (object) or file mod/foo.php (procedural)
* and use it for handling our URL request to 'https://ourgreatwebsite.something/foo' .
* The module file contains a few functions that we call in various circumstances
* and in the following order:
*
* Object:
* class Foo extends Zotlabs\Web\Controller {
* function init() { init function }
* function post() { post function }
* function get() { normal page function }
* }
*
* Procedual interface:
* foo_init()
* foo_post() (only called if there are $_POST variables)
* foo_content() - the string return of this function contains our page body
*
* Modules which emit other serialisations besides HTML (XML,JSON, etc.) should do
* so within the module init and/or post functions and then invoke killme() to terminate
* further processing.
*/
$module = \App::$module;
$modname = "Zotlabs\\Module\\" . ucfirst($module);
if (strlen($module)) {
/**
*
* We will always have a module name.
* First see if we have a plugin which is masquerading as a module.
*
*/
if (is_array(\App::$plugins) && in_array($module, \App::$plugins) && file_exists("addon/{$module}/{$module}.php")) {
include_once "addon/{$module}/{$module}.php";
if (class_exists($modname)) {
$this->controller = new $modname();
\App::$module_loaded = true;
} elseif (function_exists($module . '_module')) {
\App::$module_loaded = true;
}
}
if (strpos($module, 'admin') === 0 && !is_site_admin()) {
\App::$module_loaded = false;
notice(t('Permission denied.') . EOL);
goaway(z_root());
}
/**
* If the site has a custom module to over-ride the standard module, use it.
* Otherwise, look for the standard program module
*/
if (!\App::$module_loaded) {
try {
$filename = 'Zotlabs/SiteModule/' . ucfirst($module) . '.php';
if (file_exists($filename)) {
// This won't be picked up by the autoloader, so load it explicitly
require_once $filename;
$this->controller = new $modname();
\App::$module_loaded = true;
} else {
$filename = 'Zotlabs/Module/' . ucfirst($module) . '.php';
if (file_exists($filename)) {
$this->controller = new $modname();
\App::$module_loaded = true;
}
}
if (!\App::$module_loaded) {
throw new \Exception('Module not found');
}
} catch (\Exception $e) {
if (file_exists("mod/site/{$module}.php")) {
include_once "mod/site/{$module}.php";
\App::$module_loaded = true;
} elseif (file_exists("mod/{$module}.php")) {
include_once "mod/{$module}.php";
\App::$module_loaded = true;
}
}
}
/**
* This provides a place for plugins to register module handlers which don't otherwise exist
* on the system, or to completely over-ride an existing module.
* If the plugin sets 'installed' to true we won't throw a 404 error for the specified module even if
* there is no specific module file or matching plugin name.
* The plugin should catch at least one of the module hooks for this URL.
*/
$x = array('module' => $module, 'installed' => \App::$module_loaded, 'controller' => $this->controller);
call_hooks('module_loaded', $x);
if ($x['installed']) {
\App::$module_loaded = true;
$this->controller = $x['controller'];
}
/**
* The URL provided does not resolve to a valid module.
*
* On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'.
//.........这里部分代码省略.........
示例4: init
/**
* App constructor.
*/
public static function init()
{
// we'll reset this after we read our config file
date_default_timezone_set('UTC');
self::$config = array('system' => array());
self::$page = array();
self::$pager = array();
self::$query_string = '';
startup();
set_include_path('include' . PATH_SEPARATOR . 'library' . PATH_SEPARATOR . 'library/langdet' . PATH_SEPARATOR . '.');
self::$scheme = 'http';
if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) {
self::$scheme = 'https';
} elseif (x($_SERVER, 'SERVER_PORT') && intval($_SERVER['SERVER_PORT']) == 443) {
self::$scheme = 'https';
}
if (x($_SERVER, 'SERVER_NAME')) {
self::$hostname = $_SERVER['SERVER_NAME'];
if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
self::$hostname .= ':' . $_SERVER['SERVER_PORT'];
}
/**
* Figure out if we are running at the top of a domain
* or in a sub-directory and adjust accordingly
*/
$path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
if (isset($path) && strlen($path) && $path != self::$path) {
self::$path = $path;
}
}
set_include_path("include/self::{$hostname}" . PATH_SEPARATOR . get_include_path());
if (x($_SERVER, 'QUERY_STRING') && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
self::$query_string = substr($_SERVER['QUERY_STRING'], 2);
// removing trailing / - maybe a nginx problem
if (substr(self::$query_string, 0, 1) == "/") {
self::$query_string = substr(self::$query_string, 1);
}
}
if (x($_GET, 'q')) {
self::$cmd = trim($_GET['q'], '/\\');
}
// unix style "homedir"
if (substr(self::$cmd, 0, 1) === '~') {
self::$cmd = 'channel/' . substr(self::$cmd, 1);
}
/*
* Break the URL path into C style argc/argv style arguments for our
* modules. Given "http://example.com/module/arg1/arg2", self::$argc
* will be 3 (integer) and self::$argv will contain:
* [0] => 'module'
* [1] => 'arg1'
* [2] => 'arg2'
*
* There will always be one argument. If provided a naked domain
* URL, self::$argv[0] is set to "home".
*/
self::$argv = explode('/', self::$cmd);
self::$argc = count(self::$argv);
if (array_key_exists('0', self::$argv) && strlen(self::$argv[0])) {
self::$module = str_replace(".", "_", self::$argv[0]);
self::$module = str_replace("-", "_", self::$module);
if (strpos(self::$module, '_') === 0) {
self::$module = substr(self::$module, 1);
}
} else {
self::$argc = 1;
self::$argv = array('home');
self::$module = 'home';
}
/*
* See if there is any page number information, and initialise
* pagination
*/
self::$pager['page'] = x($_GET, 'page') && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
self::$pager['itemspage'] = 60;
self::$pager['start'] = self::$pager['page'] * self::$pager['itemspage'] - self::$pager['itemspage'];
if (self::$pager['start'] < 0) {
self::$pager['start'] = 0;
}
self::$pager['total'] = 0;
/*
* Detect mobile devices
*/
$mobile_detect = new Mobile_Detect();
self::$is_mobile = $mobile_detect->isMobile();
self::$is_tablet = $mobile_detect->isTablet();
self::head_set_icon('/images/hz-32.png');
/*
* register template engines
*/
spl_autoload_register('ZotlabsAutoloader::loader');
self::$meta = new Zotlabs\Web\HttpMeta();
// create an instance of the smarty template engine so we can register it.
$smarty = new Zotlabs\Render\SmartyTemplate();
$dc = get_declared_classes();
foreach ($dc as $k) {
if (in_array('Zotlabs\\Render\\TemplateEngine', class_implements($k))) {
//.........这里部分代码省略.........
示例5: array
}
if (!x($_SESSION, 'sysmsg')) {
$_SESSION['sysmsg'] = array();
}
if (!x($_SESSION, 'sysmsg_info')) {
$_SESSION['sysmsg_info'] = array();
}
/*
* check_config() is responsible for running update scripts. These automatically
* update the DB schema whenever we push a new one out. It also checks to see if
* any plugins have been added or removed and reacts accordingly.
*/
if (App::$install) {
/* Allow an exception for the view module so that pcss will be interpreted during installation */
if (App::$module != 'view') {
App::$module = 'setup';
}
} else {
check_config($a);
}
nav_set_selected('nothing');
$arr = array('app_menu' => App::get_apps());
call_hooks('app_menu', $arr);
App::set_apps($arr['app_menu']);
$Router = new Zotlabs\Web\Router($a);
/* initialise content region */
if (!x(App::$page, 'content')) {
App::$page['content'] = '';
}
call_hooks('page_content_top', App::$page['content']);
$Router->Dispatch($a);
示例6: implode
}
?>
</td>
</tr>
<?php
}
?>
</table>
</div>
<div class="span6">
<h2>Environment</h2>
<table class="table table-striped table-condensed">
<tr>
<th>current module</th>
<td><?php
echo App::module()->name();
?>
</td>
</tr>
<tr>
<th>loaded modules</th>
<td><?php
echo implode(", ", array_keys(Ac::loader()->getModules()));
?>
</td>
</tr>
<?php
$vars = Ac::router()->toArray();
foreach ($vars as $i => $v) {
if ($i == "controllerInstance") {
continue;
示例7: run
public function run()
{
/*
* Bootstrap the application, load configuration, load modules, load theme, etc.
*/
require_once 'boot.php';
sys_boot();
\App::$language = get_best_language();
load_translation_table(\App::$language, \App::$install);
/**
*
* Important stuff we always need to do.
*
* The order of these may be important so use caution if you think they're all
* intertwingled with no logical order and decide to sort it out. Some of the
* dependencies have changed, but at least at one time in the recent past - the
* order was critical to everything working properly
*
*/
if (\App::$session) {
\App::$session->start();
} else {
session_start();
register_shutdown_function('session_write_close');
}
/**
* Language was set earlier, but we can over-ride it in the session.
* We have to do it here because the session was just now opened.
*/
if (array_key_exists('system_language', $_POST)) {
if (strlen($_POST['system_language'])) {
$_SESSION['language'] = $_POST['system_language'];
} else {
unset($_SESSION['language']);
}
}
if (x($_SESSION, 'language') && $_SESSION['language'] !== $lang) {
\App::$language = $_SESSION['language'];
load_translation_table(\App::$language);
}
if (x($_GET, 'zid') && !\App::$install) {
\App::$query_string = strip_zids(\App::$query_string);
if (!local_channel()) {
$_SESSION['my_address'] = $_GET['zid'];
zid_init();
}
}
if (x($_GET, 'zat') && !\App::$install) {
\App::$query_string = strip_zats(\App::$query_string);
if (!local_channel()) {
zat_init();
}
}
if (x($_SESSION, 'authenticated') || x($_POST, 'auth-params') || \App::$module === 'login') {
require 'include/auth.php';
}
if (!x($_SESSION, 'sysmsg')) {
$_SESSION['sysmsg'] = array();
}
if (!x($_SESSION, 'sysmsg_info')) {
$_SESSION['sysmsg_info'] = array();
}
/*
* check_config() is responsible for running update scripts. These automatically
* update the DB schema whenever we push a new one out. It also checks to see if
* any plugins have been added or removed and reacts accordingly.
*/
if (\App::$install) {
/* Allow an exception for the view module so that pcss will be interpreted during installation */
if (\App::$module != 'view') {
\App::$module = 'setup';
}
} else {
check_config($a);
}
nav_set_selected('nothing');
$Router = new Router($a);
/* initialise content region */
if (!x(\App::$page, 'content')) {
\App::$page['content'] = '';
}
call_hooks('page_content_top', \App::$page['content']);
$Router->Dispatch($a);
// If you're just visiting, let javascript take you home
if (x($_SESSION, 'visitor_home')) {
$homebase = $_SESSION['visitor_home'];
} elseif (local_channel()) {
$homebase = z_root() . '/channel/' . \App::$channel['channel_address'];
}
if (isset($homebase)) {
\App::$page['content'] .= '<script>var homebase = "' . $homebase . '";</script>';
}
// now that we've been through the module content, see if the page reported
// a permission problem and if so, a 403 response would seem to be in order.
if (is_array($_SESSION['sysmsg']) && stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 ' . t('Permission denied.'));
}
call_hooks('page_end', \App::$page['content']);
construct_page($a);
killme();
//.........这里部分代码省略.........
示例8: function
});
Mason::directive([":each", ":endeach"], function ($a, $content, $arguments) {
return Mason::PHP("foreach( \${$a[0]} as \$i => \${$a[2]} ) : ") . "\n" . Mason::buildString($content) . "\n" . Mason::PHP("endforeach;");
});
Mason::directive([":col", ":endcol"], function ($a, $content, $arguments) {
$w = $a[0];
$res = Mason::buildString($content . " \n");
return "<div class='col-md-{$w} {$arguments['class']}' style='background-color: rgba({$arguments['color']}, 255, 255, 1)'>" . $res . "</div>";
}, DIRECTIVE_ARGS);
Mason::directive(["img", "\n"], function ($a, $b) {
$templatePath = get_template_directory_uri();
return "<img src='{$templatePath}/img/{$a[0]}' />";
});
Mason::directive(["rawImg", "\n"], function ($a, $b) {
$a = implode(" ", $a);
return "<img src='{$a}' />";
});
Mason::directive(["if", "fi"], function ($a, $b) {
}, DIRECTIVE_ARGS);
Mason::directive(['@@ ', '\\n'], function ($a) {
$class = App::module($a[0]);
if ($class) {
return Mason::EOL($class());
}
});
Mason::directive(['render', '\\n'], function ($a) {
$class = App::helper($a[0]);
if ($class) {
return Mason::EOL($class());
}
});
示例9: createThmbFileFromImage
private function createThmbFileFromImage($file)
{
$cache_file = $this->getCachedFileName($file);
if (!is_file($cache_file)) {
$ipr = App::module('Image');
$ipr->loadFromFile($file)->saveAsThumbnail($cache_file, $this->thumbnails_width, $this->thumbnails_height);
unset($ipr);
}
return $cache_file;
}
示例10: Utils
require "classes/PostOutput.php";
# \Mailer simplifies the mail class
require "classes/Mailer.php";
require "classes/BaseController.php";
require "classes/Router.php";
# Input handling
require "classes/InputRepository.php";
require "classes/Input.php";
# creates a singleton app object so that we don't have to keep reinstating the
# global variable
require "classes/App.php";
App::start();
App::instance()->autoload(dirname(__FILE__));
App::set('router', new Evo\Router());
App::set('utils', new Utils());
App::set('output', new Evo\PostOutput());
App::set('mailer', new Evo\Mailer());
require "includes/routes.php";
require "includes/endpoints.php";
$loader = new josegonzalez\Dotenv\Loader($_SERVER["DOCUMENT_ROOT"] . "/.env");
$loader->parse()->toEnv();
#-----------------------------------------
# Load static assets for the frontend and admin
# You can use these same utility functions to load
#----------------------------------------
App::module('utils')->registerAdminJavascript(Utils::getThemeAsset('/modules/example/assets/js/es5.js'));
# Some default action setup
Actions::on('parse_request', function ($queryVars) {
# populate the input singleton
Input::populate($queryVars);
}, 0, 4);
示例11: checkRoute
/**
* Checks that a given route is matched and valid. Delegates arguments
* If this is an ajax route, this outputs and exits, otherwise returns value
* @exits
* @outputs Closure
* @param \WPQuery $input
* @return Closure
*/
public function checkRoute($input)
{
$name = Input::param('routeName');
if (!$name) {
return $input;
}
$vars = Input::all();
if ($this->target === $name) {
if ($this->callback) {
$callback = $this->callback;
if (is_string($callback)) {
$temp = explode('::', $callback);
$callback = array();
$callback[0] = App::module($temp[0]);
$callback[1] = $temp[1];
}
if ($this->ajax) {
echo json_encode(call_user_func($callback, $vars));
die;
}
return call_user_func($callback, $vars);
die;
}
return '';
}
return $input;
}
示例12: function
<?php
# you can use this in order to hook into a custom upload action
# check shared.js for the relevant code
App::module('utils')->customMediaSend('exampleMediaSend', function ($args) {
$imageMeta = get_post($args->id);
$url = wp_get_attachment_image_src($args->id, 'large', true);
$thumb = wp_get_attachment_image_src($args->id, 'large', true);
return array("rawUrl" => $url[0], "thumb" => $thumb[0], "id" => $args->id, "meta" => $imageMeta);
});
示例13: _parseRouter
private static function _parseRouter()
{
$httpHost = self::getHost();
$urlArray = explode('.', $httpHost);
$module = strtolower($urlArray[0]);
$module = isset(EnvConf::$moduleMap[$module]) ? EnvConf::$moduleMap[$module] : $module;
$requestURI = self::getPath();
$_pos = strpos($requestURI, '&');
//过滤url后面的尾部
if ($_pos !== false) {
$requestURI = substr($requestURI, 0, $_pos);
}
$_pos = strpos($requestURI, '?');
if ($_pos !== false) {
$requestURI = substr($requestURI, 0, $_pos);
}
$uriArray = explode('/', trim($requestURI, '/'));
$subDir = '';
$action = 'index';
if (1 === count($uriArray) && !empty($uriArray[0])) {
$controller = strtolower($uriArray[0]);
} elseif (2 === count($uriArray)) {
$controller = strtolower($uriArray[0]);
$action = strtolower($uriArray[1]);
} elseif (3 === count($uriArray)) {
$module = strtolower($uriArray[0]);
$controller = strtolower($uriArray[1]);
$action = strtolower($uriArray[2]);
} else {
$controller = 'index';
}
if (isset($_GET['method']) && preg_match("/^[_a-zA-Z0-9-]+\$/", $_GET['method'])) {
$action = strtolower($_GET['method']);
}
if (isset($_REQUEST['module']) && !empty($_REQUEST['module'])) {
//防止线上非法访问
$_REQUEST['module'] = trim($_REQUEST['module']);
$module = strtolower($_REQUEST['module']);
}
if (isset($_REQUEST['sub_dir']) && !empty($_REQUEST['sub_dir']) && preg_match("/^[_a-zA-Z0-9-]+\$/", $_GET['sub_dir'])) {
$_REQUEST['sub_dir'] = trim($_REQUEST['sub_dir']);
$subDir = strtolower($_REQUEST['sub_dir']);
}
if (isset($_REQUEST['controller']) && !empty($_REQUEST['controller']) && preg_match("/^[_a-zA-Z0-9-]+\$/", $_GET['controller'])) {
$_REQUEST['controller'] = trim($_REQUEST['controller']);
$controller = strtolower($_REQUEST['controller']);
}
if (!preg_match("/^[_a-zA-Z0-9-]+\$/", $controller)) {
//throw new Exception("param error in url controller:".$controller);
}
//hack
if ($controller == 'favicon.ico') {
//exit(0);
//throw new Exception("param error in url controller:".$controller);
}
if (!preg_match("/^[_a-zA-Z0-9-]+\$/", $action)) {
//throw new Exception("param error in url action:".$action);
}
self::$module = $module;
self::$subDir = $subDir;
self::$controller = $controller;
self::$action = $action;
}
示例14: array
<?php
App::module('router')->collection(array('example/test' => array('action' => 'HomeController::test'), 'example/ajax' => array('ajax' => true, 'action' => function () {
# this return value will be automatically encoded
# and echoed out to the requesting server.
# if you're using jQuery's $.getJSON, it will
# be automatically parsed
return "Hello World";
})));
示例15: ucfirst
<?php
$categories = App::module('ResourceItem')->getCategoryStack(Input::param('taxonomyName'));
$mainCategory = '';
?>
<?php
get_header();
?>
<div id="content">
<div id="inner-content" class="wrap cf">
<main id="main" class="m-all t-2of3 d-5of7 cf" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog">
<article id="post-<?php
the_ID();
?>
" <?php
post_class('cf');
?>
role="article" itemscope itemtype="http://schema.org/BlogPosting">
<header class="article-header">
<h1><?php
echo ucfirst(Input::param('taxonomyName'));
?>
</h1>