本文整理汇总了PHP中module::get_var方法的典型用法代码示例。如果您正苦于以下问题:PHP module::get_var方法的具体用法?PHP module::get_var怎么用?PHP module::get_var使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module
的用法示例。
在下文中一共展示了module::get_var方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
static function get($block_id, $theme)
{
$block = "";
if (!$theme->item()) {
return;
}
switch ($block_id) {
case "embed_links_dialog":
// Display dialog buttons in the sidebar.
$block = new Block();
$block->css_id = "g-embed-links-sidebar";
$block->title = t("Link To This Page");
$block->content = new View("embedlinks_sidebar.html");
break;
case "embed_links_album":
// If the current item is an album and if "In Page" links are enabled then
// display links to the current album in the theme sidebar.
if ($theme->item()->is_album() && module::get_var("embedlinks", "InPageLinks")) {
$block = new Block();
$block->css_id = "g-embed-links-album-sidebar";
$block->title = t("Links");
$block->content = new View("embedlinks_album_block.html");
}
break;
}
return $block;
}
示例2: print_proxy
public function print_proxy($site_key, $file_id)
{
// This function retrieves the full-sized image for fotomoto.
// As this function by-passes normal Gallery security, a private
// site-key is used to try and prevent people other then fotomoto
// from finding the URL.
// If the site key doesn't match, display a 404 error.
if ($site_key != module::get_var("fotomotorw", "fotomoto_private_key")) {
throw new Kohana_404_Exception();
}
// Load the photo from the provided id. If the id# is invalid, display a 404 error.
$item = ORM::factory("item", $file_id);
if (!$item->loaded()) {
throw new Kohana_404_Exception();
}
// If the image file doesn't exist for some reason, display a 404 error.
if (!file_exists($item->file_path())) {
throw new Kohana_404_Exception();
}
// Display the image.
header("Content-Type: {$item->mime_type}");
Kohana::close_buffers(false);
$fd = fopen($item->file_path(), "rb");
fpassthru($fd);
fclose($fd);
}
示例3: index
public function index()
{
$view = new Admin_View("admin.html");
$view->page_title = t("Users and groups");
$view->page_type = "collection";
$view->page_subtype = "admin_users";
$view->content = new View("admin_users.html");
// @todo: add this as a config option
$page_size = module::get_var("user", "page_size", 10);
$page = Input::instance()->get("page", "1");
$builder = db::build();
$user_count = $builder->from("users")->count_records();
// Pagination info
$view->page = $page;
$view->page_size = $page_size;
$view->children_count = $user_count;
$view->max_pages = ceil($view->children_count / $view->page_size);
$view->content->pager = new Pagination();
$view->content->pager->initialize(array("query_string" => "page", "total_items" => $user_count, "items_per_page" => $page_size, "style" => "classic"));
// Make sure that the page references a valid offset
if ($page < 1) {
url::redirect(url::merge(array("page" => 1)));
} else {
if ($page > $view->content->pager->total_pages) {
url::redirect(url::merge(array("page" => $view->content->pager->total_pages)));
}
}
// Join our users against the items table so that we can get a count of their items
// in the same query.
$view->content->users = ORM::factory("user")->order_by("users.name", "ASC")->find_all($page_size, $view->content->pager->sql_offset);
$view->content->groups = ORM::factory("group")->order_by("name", "ASC")->find_all();
print $view;
}
示例4: photo_menu
static function photo_menu($menu, $theme)
{
if (module::get_var("ecard", "location") == "top") {
$item = $theme->item();
$menu->append(Menu::factory("link")->id("ecard")->label(t("Send as eCard"))->url(url::site("ecard/form_send/{$item->id}"))->css_class("g-dialog-link ui-icon-ecard")->css_id("g-send-ecard"));
}
}
示例5: _dump_database
private function _dump_database()
{
// We now have a clean install with just the packages that we want. Make sure that the
// database is clean too.
$i = 1;
foreach (array("blocks_dashboard_sidebar", "blocks_dashboard_center") as $key) {
$blocks = array();
foreach (unserialize(module::get_var("gallery", $key)) as $rnd => $value) {
$blocks[++$i] = $value;
}
module::set_var("gallery", $key, serialize($blocks));
}
$db = Database::instance();
$db->query("TRUNCATE {sessions}");
$db->query("TRUNCATE {logs}");
$db->query("DELETE FROM {vars} WHERE `module_name` = 'core' AND `name` = '_cache'");
$db->update("users", array("password" => ""), array("id" => 1));
$db->update("users", array("password" => ""), array("id" => 2));
$dbconfig = Kohana::config('database.default');
$conn = $dbconfig["connection"];
$pass = $conn["pass"] ? "-p{$conn['pass']}" : "";
$sql_file = DOCROOT . "installer/install.sql";
if (!is_writable($sql_file)) {
print "{$sql_file} is not writeable";
return;
}
$command = "mysqldump --compact --skip-extended-insert --add-drop-table -h{$conn['host']} " . "-u{$conn['user']} {$pass} {$conn['database']} > {$sql_file}";
exec($command, $output, $status);
if ($status) {
print "<pre>";
print "{$command}\n";
print "Failed to dump database\n";
print implode("\n", $output);
return;
}
// Post-process the sql file
$buf = "";
$root = ORM::factory("item", 1);
$root_created_timestamp = $root->created;
$root_updated_timestamp = $root->updated;
$table_name = "";
foreach (file($sql_file) as $line) {
// Prefix tables
$line = preg_replace("/(CREATE TABLE|IF EXISTS|INSERT INTO) `{$dbconfig['table_prefix']}(\\w+)`/", "\\1 {\\2}", $line);
if (preg_match("/CREATE TABLE {(\\w+)}/", $line, $matches)) {
$table_name = $matches[1];
}
// Normalize dates
$line = preg_replace("/,{$root_created_timestamp},/", ",UNIX_TIMESTAMP(),", $line);
$line = preg_replace("/,{$root_updated_timestamp},/", ",UNIX_TIMESTAMP(),", $line);
// Remove ENGINE= specifications execpt for search records, it always needs to be MyISAM
if ($table_name != "search_records") {
$line = preg_replace("/ENGINE=\\S+ /", "", $line);
}
$buf .= $line;
}
$fd = fopen($sql_file, "wb");
fwrite($fd, $buf);
fclose($fd);
}
示例6: _get_admin_form
private function _get_admin_form()
{
$form = new Forge("admin/star/save", "", "post", array("id" => "g-star-admin-form"));
$form->dropdown("show")->label(t("Default to showing..."))->options(array(0 => "All", 1 => "Starred"))->selected(module::get_var("star", "show"));
$form->submit("save")->value(t("Save"));
return $form;
}
示例7: setup
public function setup()
{
self::$installed_locales = locales::installed();
self::$default_locale = module::get_var("gallery", "default_locale");
locales::update_installed(array_keys(locales::available()));
module::set_var("gallery", "default_locale", "no_NO");
}
示例8: index
public function index()
{
// Far from perfection, but at least require view permission for the root album
$album = ORM::factory("item", 1);
access::required("view", $album);
print tag::cloud(module::get_var("tag", "tag_cloud_size", 30));
}
示例9: head
static function head($theme)
{
$v = $theme->css("photoannotation.css");
if ($theme->page_subtype == "photo") {
$v .= $theme->script("jquery.annotate.min.js");
$noborder = module::get_var("photoannotation", "noborder", false);
$noclickablehover = module::get_var("photoannotation", "noclickablehover", false);
$nohover = module::get_var("photoannotation", "nohover", false);
$bordercolor = "#" . module::get_var("photoannotation", "bordercolor", "000000");
$v .= "<style type=\"text/css\">\n";
$v .= ".photoannotation-del-button {\n\n border:1px solid " . $bordercolor . " !important;\n\n }\n";
$v .= ".photoannotation-edit-button {\n\n border:1px solid " . $bordercolor . " !important;\n\n }";
if ($noborder) {
$border_thickness = "2px";
} else {
$border_thickness = "1px";
}
if (!$noborder || !$noclickablehover || !$nohover) {
if (!$noborder) {
$v .= ".image-annotate-area {\n\n border: 1px solid " . $bordercolor . ";\n\n }\n";
$v .= ".image-annotate-area div {\n\n border: 1px solid #FFFFFF;\n\n }\n";
}
if (!$noclickablehover) {
$clickablehovercolor = "#" . module::get_var("photoannotation", "clickablehovercolor", "00AD00");
$v .= ".image-annotate-area-editable-hover div {\n\n border: " . $border_thickness . " solid " . $clickablehovercolor . " !important;\n\n }\n";
}
if (!$nohover) {
$hovercolor = "#" . module::get_var("photoannotation", "hovercolor", "990000");
$v .= ".image-annotate-area-hover div {\n\n border: " . $border_thickness . " solid " . $hovercolor . " !important;\n\n }\n";
}
}
$v .= "</style>\n";
return $v;
}
}
示例10: update
public function update()
{
//Get the ordered list of modules
$modulerawlist = explode("&", trim($_POST['modulelist'], "&"));
//Make sure that gallery and user modules are first in the list
$current_weight = 2;
$identity_provider = module::get_var("gallery", "identity_provider");
foreach ($modulerawlist as $row) {
$currentry = explode("=", $row);
$currentry = explode(":", $currentry[1]);
if ($currentry[0] == "gallery") {
$modulelist[0] = $row;
} elseif ($currentry[0] == $identity_provider) {
$modulelist[1] = $row;
} else {
$modulelist[$current_weight] = $row;
$current_weight++;
}
}
ksort($modulelist);
//Write the correct weight values
$current_weight = 0;
foreach ($modulelist as $row) {
$current_weight++;
$currentry = explode("=", $row);
$currentry = explode(":", $currentry[1]);
db::build()->update("modules")->set("weight", $current_weight)->where("id", "=", $currentry[1])->execute();
}
message::success(t("Your settings have been saved."));
url::redirect("admin/moduleorder");
print $this->_get_view();
}
示例11: update_installed
static function update_installed($locales)
{
// Ensure that the default is included...
$default = module::get_var("gallery", "default_locale");
$locales = array_merge($locales, array($default));
module::set_var("gallery", "installed_locales", join("|", $locales));
}
示例12: __construct
public function __construct()
{
$this->m_trackerUrl = module::get_var("piwik", "installation_url", null);
$this->m_tokenAuth = module::get_var("piwik", "token_auth", null);
if (empty($this->m_trackerUrl) || empty($this->m_tokenAuth)) {
$this->m_errorMessage = t("Incomplete connection settings. Cannot connect to the Piwik server");
$this->m_bInit = false;
return;
}
//TODO add an option to choice here
/* Make encrypted http connections */
$this->m_trackerUrl = substr_replace($this->m_trackerUrl, "https", 0, 4);
/* Build basic REST connection string */
if (substr($this->m_trackerUrl, -1) != "/") {
$this->m_trackerUrl .= "/";
}
$this->m_trackerUrl .= "index.php?module=API&format=php&token_auth=" . $this->m_tokenAuth;
/* Populate the sites list. This is cached once, here. */
$aIdList = $this->getAllSiteId();
if (!is_array($aIdList)) {
$this->m_bInit = false;
return;
}
foreach ($aIdList as $id) {
$idSite = $this->getSiteFromId($id);
if ($idSite === false) {
$this->m_bInit = false;
$this->m_aSites = array();
return;
}
$this->m_aSites[$id] = $idSite;
}
$this->m_bInit = true;
}
示例13: children
public function children()
{
$path = $this->input->get("path");
$tree = new View("server_add_tree.html");
$tree->files = array();
$tree->parents = array();
// Make a tree with the parents back up to the authorized path, and all the children under the
// current path.
if (server_add::is_valid_path($path)) {
$tree->parents[] = $path;
while (server_add::is_valid_path(dirname($tree->parents[0]))) {
array_unshift($tree->parents, dirname($tree->parents[0]));
}
foreach (glob("{$path}/*") as $file) {
if (!is_readable($file)) {
continue;
}
if (!is_dir($file)) {
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if (!in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) {
continue;
}
}
$tree->files[] = $file;
}
} else {
// Missing or invalid path; print out the list of authorized path
$paths = unserialize(module::get_var("server_add", "authorized_paths"));
foreach (array_keys($paths) as $path) {
$tree->files[] = $path;
}
}
print $tree;
}
示例14: rotate
/**
* Rotate an image. Valid options are degrees
*
* @param string $input_file
* @param string $output_file
* @param array $options
*/
static function rotate($input_file, $output_file, $options)
{
graphics::init_toolkit();
module::event("graphics_rotate", $input_file, $output_file, $options);
// BEGIN mod to original function
$image_info = getimagesize($input_file);
// [0]=w, [1]=h, [2]=type (1=GIF, 2=JPG, 3=PNG)
if (module::get_var("image_optimizer", "rotate_jpg") || $image_info[2] == 2) {
// rotate_jpg enabled, the file is a jpg. get args
$path = module::get_var("image_optimizer", "path_jpg");
$exec_args = " -rotate ";
$exec_args .= $options["degrees"] > 0 ? $options["degrees"] : $options["degrees"] + 360;
$exec_args .= " -copy all -optimize -outfile ";
// run it - from input_file to tmp_file
$tmp_file = image_optimizer::make_temp_name($output_file);
exec(escapeshellcmd($path) . $exec_args . escapeshellarg($tmp_file) . " " . escapeshellarg($input_file), $exec_output, $exec_status);
if ($exec_status || !filesize($tmp_file)) {
// either a blank/nonexistant file or an error - log an error and pass to normal function
Kohana_Log::add("error", "image_optimizer rotation failed on " . $output_file);
unlink($tmp_file);
} else {
// worked - move temp to output
rename($tmp_file, $output_file);
$status = true;
}
}
if (!$status) {
// we got here if we weren't supposed to use jpegtran or if jpegtran failed
// END mod to original function
Image::factory($input_file)->quality(module::get_var("gallery", "image_quality"))->rotate($options["degrees"])->save($output_file);
// BEGIN mod to original function
}
// END mod to original function
module::event("graphics_rotate_completed", $input_file, $output_file, $options);
}
示例15: required
static function required($perm_name, $item)
{
// Original code from the required function in modules/gallery/helpers/access.php.
if (!access::can($perm_name, $item)) {
if ($perm_name == "view") {
// Treat as if the item didn't exist, don't leak any information.
throw new Kohana_404_Exception();
} else {
access::forbidden();
}
// Begin rWatcher modifications.
// Throw a 404 error when a user attempts to access a protected item,
// unless the password has been provided, or the user is the item's owner.
} elseif (module::get_var("albumpassword", "hideonly") == false) {
$item_protected = ORM::factory("albumpassword_idcache")->where("item_id", "=", $item->id)->order_by("cache_id")->find_all();
if (count($item_protected) > 0) {
$existing_password = ORM::factory("items_albumpassword")->where("id", "=", $item_protected[0]->password_id)->find();
if ($existing_password->loaded()) {
if (cookie::get("g3_albumpassword") != $existing_password->password && identity::active_user()->id != $item->owner_id && !identity::active_user()->admin) {
throw new Kohana_404_Exception();
}
}
}
}
}