Exemplo n.º 1
0
 public function body_attributes()
 {
     if (locales::is_rtl()) {
         return 'class="rtl"';
     }
     return '';
 }
Exemplo n.º 2
0
 static function head($theme)
 {
     if (count(locales::installed())) {
         // Needed by the languages block
         $theme->script("jquery.cookie.js");
     }
     return "";
 }
Exemplo n.º 3
0
 private static function _add_locale_dropdown(&$form, $user = null)
 {
     $locales = locales::installed();
     if (count($locales) > 1) {
         // Put "none" at the first position in the array
         $locales = array_merge(array("" => t("« none »")), $locales);
         $selected_locale = $user && $user->locale ? $user->locale : "";
         $form->dropdown("locale")->label(t("Language Preference"))->options($locales)->selected($selected_locale);
     }
 }
Exemplo n.º 4
0
 /** @todo combine with Admin_Users_Controller::_add_locale_dropdown */
 private function _add_locale_dropdown(&$form, $user = null)
 {
     $locales = locales::installed();
     foreach ($locales as $locale => $display_name) {
         $locales[$locale] = SafeString::of_safe_html($display_name);
     }
     if (count($locales) > 1) {
         // Put "none" at the first position in the array
         $locales = array_merge(array("" => t("« none »")), $locales);
         $selected_locale = $user && $user->locale ? $user->locale : "";
         $form->dropdown("locale")->label(t("Language Preference"))->options($locales)->selected($selected_locale);
     }
 }
Exemplo n.º 5
0
 public function save()
 {
     access::verify_csrf();
     locales::update_installed($this->input->post("installed_locales"));
     $installed_locales = array_keys(locales::installed());
     $new_default_locale = $this->input->post("default_locale");
     if (!in_array($new_default_locale, $installed_locales)) {
         if (!empty($installed_locales)) {
             $new_default_locale = $installed_locales[0];
         } else {
             $new_default_locale = "en_US";
         }
     }
     module::set_var("gallery", "default_locale", $new_default_locale);
     print json_encode(array("result" => "success"));
 }
Exemplo n.º 6
0
 static function sidebar_blocks($theme)
 {
     $locales = locales::installed();
     foreach ($locales as $locale => $display_name) {
         $locales[$locale] = SafeString::of_safe_html($display_name);
     }
     if (count($locales) > 1) {
         $block = new Block();
         $block->css_id = "gUserLanguageBlock";
         $block->title = t("Select Language Preference");
         $block->content = new View("user_languages_block.html");
         $block->content->installed_locales = array_merge(array("" => t("« none »")), $locales);
         $block->content->selected = (string) user::cookie_locale();
         return $block;
     }
 }
 static function head($theme)
 {
     if ($theme->page_type == "item") {
         if (locales::is_rtl()) {
             $rtl_support = "rtl: true,\n";
         } else {
             $rtl_support = "rtl: false,\n";
         }
         $carouselwidth = module::get_var("navcarousel", "carouselwidth", "600");
         if ($carouselwidth == 0) {
             $carouselwidth = "100%";
             $containerwidth = "";
         } else {
             $carouselwidth = $carouselwidth . "px";
             $containerwidth = ".jcarousel-skin-tango .jcarousel-container-horizontal {\n\n                    width: " . $carouselwidth . ";\n\n                }\n";
         }
         $thumbsize = module::get_var("navcarousel", "thumbsize", "50");
         $theme->script("jquery.jcarousel.min.js");
         $theme->css("skin.css");
         $showelements = module::get_var("navcarousel", "showelements", "7");
         $childcount = $theme->item->parent()->viewable()->children_count();
         $itemoffset = intval(floor($showelements / 2));
         if ($childcount <= $showelements) {
             $itemoffset = 1;
         } else {
             $itempos = $theme->item->parent()->get_position($theme->item);
             $itemoffset = $itempos - $itemoffset;
             if ($itemoffset < 1) {
                 $itemoffset = 1;
             }
             if ($itemoffset + $showelements > $childcount) {
                 $itemoffset = $childcount - $showelements + 1;
             }
         }
         if (module::get_var("navcarousel", "noajax", false)) {
             $ajaxhandler = "";
         } else {
             $ajaxhandler = "itemLoadCallback: navcarousel_itemLoadCallback,\n";
         }
         if (module::get_var("navcarousel", "showondomready", false)) {
             $onwinload = "";
         } else {
             $onwinload = "});\n\n                  \$(window).load(function () {\n";
         }
         return "\n<!-- Navcaoursel -->\n                <style type=\"text/css\">\n\n                " . $containerwidth . "\n                .jcarousel-skin-tango .jcarousel-clip-horizontal {\n\n                    width:  " . $carouselwidth . ";\n\n                    height: " . ($thumbsize + 25) . "px;\n\n                }\n\n                .jcarousel-skin-tango .jcarousel-item {\n\n                    width: " . ($thumbsize + 25) . "px;\n\n                    height: " . ($thumbsize + 25) . "px;\n\n                }\n\n                #navcarousel-loader {\n\n                    height: " . ($thumbsize + 25) . "px;\n\n                }\n\n                .jcarousel-skin-tango .jcarousel-next-horizontal {\n                    top: " . intval(floor($thumbsize / 2.8)) . "px;\n                }\n                .jcarousel-skin-tango .jcarousel-prev-horizontal {\n                    top: " . intval(floor($thumbsize / 2.8)) . "px;\n                }\n                </style>\n\n                <script type=\"text/javascript\">\n\n                  jQuery(document).ready(function() {\n\n                    jQuery('#navcarousel').jcarousel({\n\n                        " . $ajaxhandler . "\n                        itemFallbackDimension: " . ($thumbsize + 25) . ",\n\n                        start: " . $itemoffset . ",\n\n                        size: " . $childcount . ",\n\n                        visible: " . $showelements . ",\n\n                        " . $rtl_support . "\n                        scroll: " . module::get_var("navcarousel", "scrollsize", "7") . "\n\n                    });\n\n                  " . $onwinload . "\n                    \$(\".jcarousel-prev-horizontal\").css(\"visibility\", \"visible\");\n\n                    \$(\".jcarousel-next-horizontal\").css(\"visibility\", \"visible\");\n\n                    \$(\"#navcarousel\").css(\"visibility\", \"visible\");\n\n                    \$(\"#navcarousel-wrapper\").css(\"background\", \"none\");\n\n                    \$(\"#navcarousel-wrapper\").css(\"float\", \"left\");\n\n                  });\n\n                </script>\n\n                <!-- Navcaoursel -->";
     }
 }
Exemplo n.º 8
0
 static function set_request_locale()
 {
     // 1. Check the session specific preference (cookie)
     $locale = user::cookie_locale();
     // 2. Check the user's preference
     if (!$locale) {
         $locale = user::active()->locale;
     }
     // 3. Check the browser's / OS' preference
     if (!$locale) {
         $locale = locales::locale_from_http_request();
     }
     // If we have any preference, override the site's default locale
     if ($locale) {
         I18n::instance()->locale($locale);
     }
 }
Exemplo n.º 9
0
 static function get($block_id, $theme)
 {
     $block = "";
     switch ($block_id) {
         case "language":
             $locales = locales::installed();
             foreach ($locales as $locale => $display_name) {
                 $locales[$locale] = SafeString::of_safe_html($display_name);
             }
             if (count($locales) > 1) {
                 $block = new Block();
                 $block->css_id = "g-user-language-block";
                 $block->title = t("Language Preference");
                 $block->content = new View("user_languages_block.html");
                 $block->content->installed_locales = array_merge(array("" => t("« none »")), $locales);
                 $block->content->selected = (string) user::cookie_locale();
             }
             break;
     }
     return $block;
 }
Exemplo n.º 10
0
    <? if (!Input::instance()->get('show_all_l10n_messages')): ?>
      <a style="background-color:#fff" href="<?php 
echo url::site("admin/languages?show_all_l10n_messages=1");
?>
"><?php 
echo t("(Show all)");
?>
</a>
    <? endif; ?>
    </h2></div>
    <div class="label source"><h2><?php 
echo t("Source");
?>
</div>
    <div class="label translation"><h2><?php 
echo t("Translation to %language", array("language" => locales::display_name()));
?>
</h2></div>
  </div>
  <div id="l10n-client-string-select">
    <ul class="string-list">
      <? foreach ($string_list as $string): ?>
      <li class="<?php 
echo $string["translation"] === "" ? "untranslated" : "translated";
?>
">
        <? if (is_array($string["source"])): ?>
       [one] - <?php 
echo $string["source"]["one"];
?>
<br/>
Exemplo n.º 11
0
 static function cookie_locale()
 {
     $cookie_data = Input::instance()->cookie("g_locale");
     $locale = null;
     if ($cookie_data) {
         if (preg_match("/^([a-z]{2,3}(?:_[A-Z]{2})?)\$/", trim($cookie_data), $matches)) {
             $requested_locale = $matches[1];
             $installed_locales = locales::installed();
             if (isset($installed_locales[$requested_locale])) {
                 $locale = $requested_locale;
             }
         }
     }
     return $locale;
 }
Exemplo n.º 12
0
 static function show_user_profile($data)
 {
     $v = new View("user_profile_info.html");
     $fields = array("name" => t("Name"), "locale" => t("Language Preference"), "email" => t("Email"), "full_name" => t("Full name"), "url" => "Web site");
     if (!$data->user->guest) {
         $fields = array("name" => t("Name"), "full_name" => t("Full name"), "url" => "Web site");
     }
     $v->user_profile_data = array();
     foreach ($fields as $field => $label) {
         if (!empty($data->user->{$field})) {
             $value = $data->user->{$field};
             if ($field == "locale") {
                 $value = locales::display_name($value);
             }
             $v->user_profile_data[(string) $label] = $value;
         }
     }
     $data->content[] = (object) array("title" => t("User information"), "view" => $v);
 }
Exemplo n.º 13
0
 public function locale_from_http_request_prefer_inexact_same_language_match_over_exact_other_language_match_test()
 {
     locales::update_installed(array("de_DE", "ar_AR", "fa_IR", "he_IL", "en_US"));
     // Accept-Language header from Firefox 3.5/Ubuntu
     $_SERVER["HTTP_ACCEPT_LANGUAGE"] = "he,en-us;q=0.9,de-ch;q=0.5,en;q=0.3";
     $locale = locales::locale_from_http_request();
     $this->assert_equal("he_IL", $locale);
 }
Exemplo n.º 14
0
 /**
  * @return an array of messages that will be written to the task log
  */
 static function fetch_updates()
 {
     $request->locales = array();
     $request->messages = new stdClass();
     $locales = locales::installed();
     foreach ($locales as $locale => $locale_data) {
         $request->locales[] = $locale;
     }
     // @todo Batch requests (max request size)
     foreach (Database::instance()->select("key", "locale", "revision", "translation")->from("incoming_translations")->get()->as_array() as $row) {
         if (!isset($request->messages->{$row->key})) {
             $request->messages->{$row->key} = 1;
         }
         if (!empty($row->revision) && !empty($row->translation)) {
             if (!is_object($request->messages->{$row->key})) {
                 $request->messages->{$row->key} = new stdClass();
             }
             $request->messages->{$row->key}->{$row->locale} = $row->revision;
         }
     }
     // @todo Include messages from outgoing_translations?
     $request_data = json_encode($request);
     $url = self::_server_url() . "?q=translations/fetch";
     list($response_data, $response_status) = remote::post($url, array("data" => $request_data));
     if (!remote::success($response_status)) {
         throw new Exception("@todo TRANSLATIONS_FETCH_REQUEST_FAILED " . $response_status);
     }
     if (empty($response_data)) {
         return array(t("Translations fetch request resulted in an empty response"));
     }
     $response = json_decode($response_data);
     // Response format (JSON payload):
     //   [{key:<key_1>, translation: <JSON encoded translation>, rev:<rev>, locale:<locale>},
     //    {key:<key_2>, ...}
     //   ]
     foreach ($response as $message_data) {
         // @todo Better input validation
         if (empty($message_data->key) || empty($message_data->translation) || empty($message_data->locale) || empty($message_data->rev)) {
             throw new Exception("@todo TRANSLATIONS_FETCH_REQUEST_FAILED: Invalid response data");
         }
         $key = $message_data->key;
         $locale = $message_data->locale;
         $revision = $message_data->rev;
         $translation = json_decode($message_data->translation);
         if (!is_string($translation)) {
             // Normalize stdclass to array
             $translation = (array) $translation;
         }
         $translation = serialize($translation);
         // @todo Should we normalize the incoming_translations table into messages(id, key, message)
         // and incoming_translations(id, translation, locale, revision)? Or just allow
         // incoming_translations.message to be NULL?
         $locale = $message_data->locale;
         $entry = ORM::factory("incoming_translation")->where(array("key" => $key, "locale" => $locale))->find();
         if (!$entry->loaded) {
             // @todo Load a message key -> message (text) dict into memory outside of this loop
             $root_entry = ORM::factory("incoming_translation")->where(array("key" => $key, "locale" => "root"))->find();
             $entry->key = $key;
             $entry->message = $root_entry->message;
             $entry->locale = $locale;
         }
         $entry->revision = $revision;
         $entry->translation = $translation;
         $entry->save();
     }
 }
Exemplo n.º 15
0
echo t("Translating Gallery");
?>
</h3>

        <p><?php 
echo t("Follow these steps to begin translating Gallery.");
?>
</p>

        <ul>
          <li><?php 
echo t("Make sure the target language is installed and up to date (check above).");
?>
</li>
          <li><?php 
echo t("Make sure you have selected the right target language (currently %default_locale).", array("default_locale" => locales::display_name()));
?>
</li>
          <li><?php 
echo t("Start the translation mode and the translation interface will appear at the bottom of each Gallery page.");
?>
</li>
        </ul>
        <a href="<?php 
echo url::site("l10n_client/toggle_l10n_mode?csrf=" . access::csrf_token());
?>
"
           class="g-button ui-state-default ui-corner-all ui-icon-left">
          <span class="ui-icon ui-icon-power"></span>
          <?php 
if (Session::instance()->get("l10n_mode", false)) {
Exemplo n.º 16
0
 private function _languages_form()
 {
     $all_locales = locales::available();
     $installed_locales = locales::installed();
     $form = new Forge("admin/languages/save", "", "post", array("id" => "gLanguageSettingsForm"));
     $group = $form->group("choose_language")->label(t("Language settings"));
     $group->dropdown("locale")->options($installed_locales)->selected(module::get_var("gallery", "default_locale"))->label(t("Default language"))->rules('required');
     $installation_options = array();
     foreach ($all_locales as $code => $display_name) {
         $installation_options[$code] = array($display_name, isset($installed_locales->{$code}));
     }
     $group->checklist("installed_locales")->label(t("Installed Languages"))->options($installation_options)->rules("required");
     $group->submit("save")->value(t("Save settings"));
     return $form;
 }
Exemplo n.º 17
0
 static function get($block_id)
 {
     $block = new Block();
     switch ($block_id) {
         case "welcome":
             $block->css_id = "g-welcome";
             $block->title = t("Welcome to Gallery 3");
             $block->content = new View("admin_block_welcome.html");
             break;
         case "photo_stream":
             $block->css_id = "g-photo-stream";
             $block->title = t("Photo stream");
             $block->content = new View("admin_block_photo_stream.html");
             $block->content->photos = ORM::factory("item")->where("type", "=", "photo")->order_by("created", "DESC")->find_all(10);
             break;
         case "log_entries":
             $block->css_id = "g-log-entries";
             $block->title = t("Log entries");
             $block->content = new View("admin_block_log_entries.html");
             $block->content->entries = ORM::factory("log")->order_by(array("timestamp" => "DESC", "id" => "DESC"))->find_all(5);
             break;
         case "stats":
             $block->css_id = "g-stats";
             $block->title = t("Gallery stats");
             $block->content = new View("admin_block_stats.html");
             $block->content->album_count = ORM::factory("item")->where("type", "=", "album")->where("id", "<>", 1)->count_all();
             $block->content->photo_count = ORM::factory("item")->where("type", "=", "photo")->count_all();
             break;
         case "platform_info":
             $block->css_id = "g-platform";
             $block->title = t("Platform information");
             $block->content = new View("admin_block_platform.html");
             break;
         case "project_news":
             $block->css_id = "g-project-news";
             $block->title = t("Gallery project news");
             $block->content = new View("admin_block_news.html");
             $block->content->feed = feed::parse("http://gallery.menalto.com/node/feed", 3);
             break;
         case "block_adder":
             $block->css_id = "g-block-adder";
             $block->title = t("Dashboard content");
             $block->content = gallery_block::get_add_block_form();
             break;
         case "language":
             $locales = locales::installed();
             if (count($locales) > 1) {
                 foreach ($locales as $locale => $display_name) {
                     $locales[$locale] = SafeString::of_safe_html($display_name);
                 }
                 $block = new Block();
                 $block->css_id = "g-user-language-block";
                 $block->title = t("Language preference");
                 $block->content = new View("user_languages_block.html");
                 $block->content->installed_locales = array_merge(array("" => t("« none »")), $locales);
                 $block->content->selected = (string) locales::cookie_locale();
             } else {
                 $block = "";
             }
             break;
         case "upgrade_checker":
             $block = new Block();
             $block->css_id = "g-upgrade-available-block";
             $block->title = t("Check for Gallery upgrades");
             $block->content = new View("upgrade_checker_block.html");
             $block->content->version_info = upgrade_checker::version_info();
             $block->content->auto_check_enabled = upgrade_checker::auto_check_enabled();
             $block->content->new_version = upgrade_checker::get_upgrade_message();
     }
     return $block;
 }
Exemplo n.º 18
0
 /**
  * Initialization.
  */
 static function gallery_ready()
 {
     user::load_user();
     locales::set_request_locale();
 }
Exemplo n.º 19
0
 /**
  * Fetches translations for l10n messages. Must be called repeatedly
  * until 0 is returned (which is a countdown indicating progress).
  *
  * @param $num_fetched in/out parameter to specify which batch of
  *     messages to fetch translations for.
  * @return The number of messages for which we didn't fetch
  *     translations for.
  */
 static function fetch_updates(&$num_fetched)
 {
     $request = new stdClass();
     $request->locales = array();
     $request->messages = new stdClass();
     $locales = locales::installed();
     foreach ($locales as $locale => $locale_data) {
         $request->locales[] = $locale;
     }
     // See the server side code for how we arrive at this
     // number as a good limit for #locales * #messages.
     $max_messages = 2000 / count($locales);
     $num_messages = 0;
     $rows = db::build()->select("key", "locale", "revision", "translation")->from("incoming_translations")->order_by("key")->limit(1000000)->offset($num_fetched)->execute();
     $num_remaining = $rows->count();
     foreach ($rows as $row) {
         if (!isset($request->messages->{$row->key})) {
             if ($num_messages >= $max_messages) {
                 break;
             }
             $request->messages->{$row->key} = 1;
             $num_messages++;
         }
         if (!empty($row->revision) && !empty($row->translation) && isset($locales[$row->locale])) {
             if (!is_object($request->messages->{$row->key})) {
                 $request->messages->{$row->key} = new stdClass();
             }
             $request->messages->{$row->key}->{$row->locale} = (int) $row->revision;
         }
         $num_fetched++;
         $num_remaining--;
     }
     // @todo Include messages from outgoing_translations?
     if (!$num_messages) {
         return $num_remaining;
     }
     $request_data = json_encode($request);
     $url = self::_server_url("fetch");
     list($response_data, $response_status) = remote::post($url, array("data" => $request_data));
     if (!remote::success($response_status)) {
         throw new Exception("@todo TRANSLATIONS_FETCH_REQUEST_FAILED " . $response_status);
     }
     if (empty($response_data)) {
         return $num_remaining;
     }
     $response = json_decode($response_data);
     // Response format (JSON payload):
     //   [{key:<key_1>, translation: <JSON encoded translation>, rev:<rev>, locale:<locale>},
     //    {key:<key_2>, ...}
     //   ]
     foreach ($response as $message_data) {
         // @todo Better input validation
         if (empty($message_data->key) || empty($message_data->translation) || empty($message_data->locale) || empty($message_data->rev)) {
             throw new Exception("@todo TRANSLATIONS_FETCH_REQUEST_FAILED: Invalid response data");
         }
         $key = $message_data->key;
         $locale = $message_data->locale;
         $revision = $message_data->rev;
         $translation = json_decode($message_data->translation);
         if (!is_string($translation)) {
             // Normalize stdclass to array
             $translation = (array) $translation;
         }
         $translation = serialize($translation);
         // @todo Should we normalize the incoming_translations table into messages(id, key, message)
         // and incoming_translations(id, translation, locale, revision)? Or just allow
         // incoming_translations.message to be NULL?
         $locale = $message_data->locale;
         $entry = ORM::factory("incoming_translation")->where("key", "=", $key)->where("locale", "=", $locale)->find();
         if (!$entry->loaded()) {
             // @todo Load a message key -> message (text) dict into memory outside of this loop
             $root_entry = ORM::factory("incoming_translation")->where("key", "=", $key)->where("locale", "=", "root")->find();
             $entry->key = $key;
             $entry->message = $root_entry->message;
             $entry->locale = $locale;
         }
         $entry->revision = $revision;
         $entry->translation = $translation;
         $entry->save();
     }
     return $num_remaining;
 }
Exemplo n.º 20
0
 static function create_pending_request($form)
 {
     $email_verification = module::get_var("registration", "email_verification");
     $user = ORM::factory("pending_user");
     $user->name = $form->register_user->inputs["name"]->value;
     $user->full_name = $form->register_user->inputs["full_name"]->value;
     $user->email = $form->register_user->inputs["email"]->value;
     $user->url = $form->register_user->inputs["url"]->value;
     $user->request_date = time();
     // added by Shad Laws, v2
     $user->locale = locales::locale_from_http_request() ? locales::locale_from_http_request() : module::get_var("gallery", "default_locale");
     // sets default locale based on browser
     if (!$email_verification) {
         $user->state = 1;
     }
     $user->hash = md5(rand());
     $user->save();
     return $user;
 }
<iframe src="http://www.facebook.com/plugins/like.php?app_id=<?php 
    echo $appId;
    ?>
&amp;href=<?php 
    echo $selfURL;
    ?>
&amp;layout=<?php 
    echo $layout;
    ?>
&amp;send=false
&amp;show_faces=<?php 
    echo $show_faces;
    ?>
&amp;width=180
&amp;locale=<?php 
    echo locales::cookie_locale();
    ?>
&amp;action=<?php 
    echo $action;
    ?>
&amp;colorscheme=light&amp;height=<?php 
    echo $hite;
    ?>
" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:180px; height:<?php 
    echo $hite;
    ?>
px;" allowTransparency="true">
</iframe>

<?php 
} else {
Exemplo n.º 22
0
 /**
  * Initialization.
  */
 static function gallery_ready()
 {
     identity::load_user();
     theme::load_themes();
     locales::set_request_locale();
 }
Exemplo n.º 23
0
 static function cookie_locale()
 {
     // Can't use Input framework for client side cookies since
     // they're not signed.
     $cookie_data = isset($_COOKIE["g_locale"]) ? $_COOKIE["g_locale"] : null;
     $locale = null;
     if ($cookie_data) {
         if (preg_match("/^([a-z]{2,3}(?:_[A-Z]{2})?)\$/", trim($cookie_data), $matches)) {
             $requested_locale = $matches[1];
             $installed_locales = locales::installed();
             if (isset($installed_locales[$requested_locale])) {
                 $locale = $requested_locale;
             }
         }
     }
     return $locale;
 }
Exemplo n.º 24
0
  <head>
    <title><?php 
echo t("Gallery 3 upgrader");
?>
</title>
    <link rel="stylesheet" type="text/css" href="<?php 
echo url::file("modules/gallery/css/upgrader.css");
?>
"
          media="screen,print,projection" />
    <script src="<?php 
echo url::file("lib/jquery.js");
?>
" type="text/javascript"></script>
  </head>
  <body<? if (locales::is_rtl()) { echo ' class="rtl"'; } ?>>
    <div id="outer">
      <img id="logo" src="<?php 
echo url::file("modules/gallery/images/gallery.png");
?>
" />
      <div id="inner">
        <? if ($can_upgrade): ?>
        <div id="dialog" style="visibility: hidden">
          <a id="dialog_close_link" style="display: none" onclick="$('#dialog').fadeOut(); return false;" href="#" class="close">[x]</a>
          <div id="busy" style="display: none">
            <h1>
              <img width="16" height="16" src="<?php 
echo url::file("themes/wind/images/loading-small.gif");
?>
"/>
<?php

defined("SYSPATH") or die("No direct script access.");
// Check and see if the current photo has any faces or notes associated with it.
$existingUsers = ORM::factory("items_user")->where("item_id", "=", $item->id)->find_all();
$existingFaces = ORM::factory("items_face")->where("item_id", "=", $item->id)->find_all();
$existingNotes = ORM::factory("items_note")->where("item_id", "=", $item->id)->find_all();
$fullname = module::get_var("photoannotation", "fullname", false);
$showusers = module::get_var("photoannotation", "showusers", false);
$showfaces = module::get_var("photoannotation", "showfaces", false);
$shownotes = module::get_var("photoannotation", "shownotes", false);
if (locales::is_rtl()) {
    $rtl_support = "image-annotate-rtl";
} else {
    $rtl_support = "";
}
$tags_arraystring = "";
$jscode = "";
$legend_faces = "";
$legend_notes = "";
$legend_users = "";
if (module::get_var("gallery", "active_site_theme") == "greydragon") {
    $css_item_id = "#g-photo-id-" . $item->id;
    $css_a_class = ".g-sb-preview";
} else {
    $css_item_id = "#g-item-id-" . $item->id;
    $css_a_class = ".g-fullsize-link";
}
// If it does, then insert some javascript and display an image map
//   to show where the faces are at.
if (count($existingFaces) > 0 || count($existingNotes) > 0 || count($existingUsers) > 0) {
Exemplo n.º 26
0
 static function get($block_id)
 {
     $block = new Block();
     switch ($block_id) {
         case "welcome":
             $block->css_id = "g-welcome";
             $block->title = t("Welcome to Gallery 3");
             $block->content = new View("admin_block_welcome.html");
             break;
         case "photo_stream":
             $block->css_id = "g-photo-stream";
             $block->title = t("Photo Stream");
             $block->content = new View("admin_block_photo_stream.html");
             $block->content->photos = ORM::factory("item")->where("type", "photo")->orderby("created", "DESC")->find_all(10);
             break;
         case "log_entries":
             $block->css_id = "g-log-entries";
             $block->title = t("Log Entries");
             $block->content = new View("admin_block_log_entries.html");
             $block->content->entries = ORM::factory("log")->orderby(array("timestamp" => "DESC", "id" => "DESC"))->find_all(5);
             break;
         case "stats":
             $block->css_id = "g-stats";
             $block->title = t("Gallery Stats");
             $block->content = new View("admin_block_stats.html");
             $block->content->album_count = ORM::factory("item")->where("type", "album")->where("id <>", 1)->count_all();
             $block->content->photo_count = ORM::factory("item")->where("type", "photo")->count_all();
             break;
         case "platform_info":
             $block->css_id = "g-platform";
             $block->title = t("Platform Information");
             $block->content = new View("admin_block_platform.html");
             if (is_readable("/proc/loadavg")) {
                 $block->content->load_average = join(" ", array_slice(split(" ", array_shift(file("/proc/loadavg"))), 0, 3));
             } else {
                 $block->content->load_average = t("Unavailable");
             }
             break;
         case "project_news":
             $block->css_id = "g-project-news";
             $block->title = t("Gallery Project News");
             $block->content = new View("admin_block_news.html");
             $block->content->feed = feed::parse("http://gallery.menalto.com/node/feed", 3);
             break;
         case "block_adder":
             $block->css_id = "g-block-adder";
             $block->title = t("Dashboard Content");
             $block->content = self::get_add_block_form();
             break;
         case "language":
             $locales = locales::installed();
             if (count($locales)) {
                 foreach ($locales as $locale => $display_name) {
                     $locales[$locale] = SafeString::of_safe_html($display_name);
                 }
                 $block = new Block();
                 $block->css_id = "g-user-language-block";
                 $block->title = t("Language Preference");
                 $block->content = new View("user_languages_block.html");
                 $block->content->installed_locales = array_merge(array("" => t("« none »")), $locales);
                 $block->content->selected = (string) locales::cookie_locale();
             } else {
                 $block = "";
             }
             break;
     }
     return $block;
 }