/**
  * Load and return user metadata from given file
  *
  * @param string $fileName Path to user file to unserialize
  * @return array GalleryStatus a status code,
  *               object Unserialized user metadata
  */
 function loadFile($fileName)
 {
     $fileName = str_replace('//', '/', $fileName);
     if (!file_exists($fileName) || !is_readable($fileName)) {
         if (file_exists($fileName . '.bak') && is_readable($fileName . '.bak')) {
             $fileName .= '.bak';
         } else {
             message::warning(t('Gallery1 inconsistency: Missing or not readable file %file', array('file' => $fileName)));
             return array('ERROR_BAD_PARAMETER', null);
         }
     }
     $tmp = file($fileName);
     if (empty($tmp)) {
         message::warning(t('Gallery1 inconsistency: Empty file %file', array('file' => $fileName)));
         return array('ERROR_MISSING_VALUE', null);
     }
     $tmp = join('', $tmp);
     /*
      * We renamed User.php to Gallery_User.php in v1.2, so port forward
      * any saved user objects.
      */
     if (stripos($tmp, 'O:4:"user"') !== false) {
         $tmp = str_ireplace('O:4:"user"', 'O:12:"gallery_user"', $tmp);
     }
     /*
      * Gallery3 already contains a class named Image so
      * we need to rename the G1 Image class to G1Img here
      */
     if (stripos($tmp, 'O:5:"image"') !== false) {
         $tmp = str_ireplace('O:5:"image"', 'O:5:"G1Img"', $tmp);
     }
     $object = unserialize($tmp);
     return array(null, $object);
 }
Esempio n. 2
0
function bootstrap_panel($title, $content, $buttons = false)
{
    $class = '';
    $clearfix = '';
    try {
        if ($buttons !== false) {
            if (!is_array($buttons) && dyn::get('debug')) {
                throw new InvalidArgumentException('$buttons must be an array');
            }
            $class = ' pull-left';
            $clearfix = '<div class="clearfix"></div>';
            $buttons = '<div class="btn-group pull-right">' . PHP_EOL . implode(PHP_EOL, (array) $buttons) . '</div>';
        }
    } catch (InvalidArgumentException $e) {
        echo message::warning($e->getMessage());
    }
    echo '<div class="row">
        <div class="col-lg-12">
        	<div id="ajax-content"></div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title' . $class . '">' . $title . '</h3>
                   ' . $buttons . '
				   ' . $clearfix . '                  
                </div>
                ' . $content . '
            </div>
        </div>
    </div>';
}
Esempio n. 3
0
 public static function deleteFile($id)
 {
     $values = [];
     for ($i = 1; $i <= 10; $i++) {
         $values[] = '`media' . $i . '` = ' . $id;
     }
     for ($i = 1; $i <= 10; $i++) {
         $values[] = '`medialist' . $i . '` LIKE "%|' . $id . '|%"';
     }
     $sql = sql::factory();
     $sql->query('SELECT id FROM ' . sql::table('structure_area') . ' WHERE ' . implode(' OR ', $values))->result();
     if ($sql->num()) {
         echo message::warning(lang::get('file_in_use'));
     } else {
         $sql = sql::factory();
         $sql->setTable('media');
         $sql->setWhere('id=' . $id);
         $sql->select('filename');
         $sql->result();
         if (unlink(dir::media($sql->get('filename')))) {
             $sql->delete();
             return message::success(lang::get('file_deleted'), true);
         } else {
             return message::warning(sprintf(lang::get('file_not_deleted'), dyn::get('hp_url'), $sql->get('filename')), true);
         }
     }
 }
Esempio n. 4
0
 /**
  * Attempts to load a view and pre-load view data.
  *
  * @throws  Kohana_Exception  if the requested view cannot be found
  * @param   string  $name view name
  * @param   string  $page_type page type: album, photo, tags, etc
  * @param   string  $theme_name view name
  * @return  void
  */
 public function __construct($name, $page_type)
 {
     $theme_name = module::get_var("gallery", "active_site_theme");
     if (!file_exists("themes/{$theme_name}")) {
         module::set_var("gallery", "active_site_theme", "default");
         theme::load_themes();
         Kohana::log("error", "Unable to locate theme '{$theme_name}', switching to default theme.");
     }
     parent::__construct($name);
     $this->theme_name = module::get_var("gallery", "active_site_theme");
     if (user::active()->admin) {
         $this->theme_name = Input::instance()->get("theme", $this->theme_name);
     }
     $this->item = null;
     $this->tag = null;
     $this->set_global("theme", $this);
     $this->set_global("user", user::active());
     $this->set_global("page_type", $page_type);
     $this->set_global("page_title", null);
     if ($page_type == "album") {
         $this->set_global("thumb_proportion", $this->thumb_proportion());
     }
     $maintenance_mode = Kohana::config("core.maintenance_mode", false, false);
     if ($maintenance_mode) {
         message::warning(t("This site is currently in maintenance mode"));
     }
 }
Esempio n. 5
0
 public function handler()
 {
     access::verify_csrf();
     $form = $this->_get_form();
     if ($form->validate()) {
         $scrollsize = intval($form->navcarousel->scrollsize->value);
         $showelements = intval($form->navcarousel->showelements->value);
         $carouselwidth = intval($form->navcarousel->carouselwidth->value);
         $thumbsize = intval($form->thumbsettings->thumbsize->value);
         if ($showelements < 1) {
             $showelements = 1;
             message::error(t("You must show at least one item."));
         }
         if ($scrollsize < 1) {
             $scrollsize = 1;
             message::error(t("You must scroll by at least one item."));
         }
         if ($thumbsize > 150 || $thumbsize < 25) {
             $thumbsize = 50;
             message::error(t("The size of the thumbnails must be between 25 and 150 pixel."));
         }
         if ($carouselwidth < $thumbsize + 75 && $carouselwidth > 0) {
             $carouselwidth = $thumbsize + 75;
             message::error(t("The carousel must be at least %pixel wide.", array("pixel" => $carouselwidth)));
         }
         if ($carouselwidth > 0) {
             if ($carouselwidth < ($thumbsize + 11) * $showelements + 64) {
                 $showelements = ($carouselwidth - 64) / ($thumbsize + 11);
                 $showelements = intval(floor($showelements));
                 message::error(t("With the selected carousel width and thumbnail size you can show a maximum of %itemno items.", array("itemno" => $showelements)));
             }
         } else {
             message::warning(t("The maximum number of displayable items cannot be calculated when the carousel width is set to 0."));
         }
         if ($scrollsize > $showelements) {
             $scrollsize = $showelements;
             message::error(t("The number of items to scroll must not exceed the number of items to show."));
         }
         module::set_var("navcarousel", "scrollsize", $scrollsize);
         module::set_var("navcarousel", "showelements", $showelements);
         module::set_var("navcarousel", "carouselwidth", $carouselwidth);
         module::set_var("navcarousel", "thumbsize", $thumbsize);
         module::set_var("navcarousel", "abovephoto", $form->navcarousel->abovephoto->value, true);
         module::set_var("navcarousel", "noajax", $form->navcarousel->noajax->value, true);
         module::set_var("navcarousel", "showondomready", $form->navcarousel->showondomready->value, true);
         module::set_var("navcarousel", "maintainaspect", $form->thumbsettings->maintainaspect->value, true);
         module::set_var("navcarousel", "nomouseover", $form->thumbsettings->nomouseover->value, true);
         module::set_var("navcarousel", "noresize", $form->thumbsettings->noresize->value, true);
         message::success(t("Your settings have been saved."));
         url::redirect("admin/navcarousel");
     }
     print $this->_get_view($form);
 }
Esempio n. 6
0
 static function site_menu($menu, $theme)
 {
     if ($theme->page_type != "login") {
         $menu->append(Menu::factory("link")->id("home")->label(t("Home"))->url(item::root()->url()));
         $item = $theme->item();
         if (!empty($item)) {
             $can_edit = $item && access::can("edit", $item);
             $can_add = $item && access::can("add", $item);
             if ($can_add) {
                 $menu->append($add_menu = Menu::factory("submenu")->id("add_menu")->label(t("Add")));
                 $is_album_writable = is_writable($item->is_album() ? $item->file_path() : $item->parent()->file_path());
                 if ($is_album_writable) {
                     $add_menu->append(Menu::factory("dialog")->id("add_photos_item")->label(t("Add photos"))->url(url::site("simple_uploader/app/{$item->id}")));
                     if ($item->is_album()) {
                         $add_menu->append(Menu::factory("dialog")->id("add_album_item")->label(t("Add an album"))->url(url::site("form/add/albums/{$item->id}?type=album")));
                     }
                 } else {
                     message::warning(t("The album '%album_name' is not writable.", array("album_name" => $item->title)));
                 }
             }
             switch ($item->type) {
                 case "album":
                     $option_text = t("Album options");
                     $edit_text = t("Edit album");
                     break;
                 case "movie":
                     $option_text = t("Movie options");
                     $edit_text = t("Edit movie");
                     break;
                 default:
                     $option_text = t("Photo options");
                     $edit_text = t("Edit photo");
             }
             $menu->append($options_menu = Menu::factory("submenu")->id("options_menu")->label($option_text));
             if ($item && ($can_edit || $can_add)) {
                 if ($can_edit) {
                     $options_menu->append(Menu::factory("dialog")->id("edit_item")->label($edit_text)->url(url::site("form/edit/{$item->type}s/{$item->id}")));
                 }
                 if ($item->is_album()) {
                     if ($can_edit) {
                         $options_menu->append(Menu::factory("dialog")->id("edit_permissions")->label(t("Edit permissions"))->url(url::site("permissions/browse/{$item->id}")));
                     }
                 }
             }
         }
         if (user::active()->admin) {
             $menu->append($admin_menu = Menu::factory("submenu")->id("admin_menu")->label(t("Admin")));
             module::event("admin_menu", $admin_menu, $theme);
         }
     }
 }
Esempio n. 7
0
 public function doClear($id)
 {
     $photo = ORM::factory("item", $id);
     $rateid = "rate" . $id;
     $ratable = db::build()->select("id")->from("ratables")->where("ratableKey", "=", $rateid)->execute()->current();
     if (db::build()->select("id")->from("ratings")->where("ratable_id", "=", $ratable->id)->execute()->count() < 1) {
         message::warning(t("No votes have been registered for this item:  Nothing cleared!"));
         json::reply(array("result" => "success", "location" => $photo->url()));
         return;
     }
     $ratings = db::build()->delete("ratings")->where("ratable_id", "=", $ratable->id)->execute();
     message::success(t("All ratings and votes for this item have been cleared!"));
     json::reply(array("result" => "success", "location" => $photo->url()));
 }
Esempio n. 8
0
 public function index()
 {
     g2_import::lower_error_reporting();
     if (g2_import::is_configured()) {
         g2_import::init();
     }
     $view = new Admin_View("admin.html");
     $view->page_title = t("Gallery 2 import");
     $view->content = new View("admin_g2_import.html");
     if (class_exists("GalleryCoreApi")) {
         $view->content->g2_stats = $g2_stats = g2_import::g2_stats();
         $view->content->g3_stats = $g3_stats = g2_import::g3_stats();
         $view->content->g2_sizes = g2_import::common_sizes();
         $view->content->g2_version = g2_import::version();
         // Don't count tags because we don't track them in g2_map
         $view->content->g2_resource_count = $g2_stats["users"] + $g2_stats["groups"] + $g2_stats["albums"] + $g2_stats["photos"] + $g2_stats["movies"] + $g2_stats["comments"];
         $view->content->g3_resource_count = $g3_stats["user"] + $g3_stats["group"] + $g3_stats["album"] + $g3_stats["item"] + $g3_stats["comment"] + $g3_stats["tag"];
     }
     $view->content->form = $this->_get_import_form();
     $view->content->version = "";
     $view->content->thumb_size = module::get_var("gallery", "thumb_size");
     $view->content->resize_size = module::get_var("gallery", "resize_size");
     if (g2_import::is_initialized()) {
         if ((bool) ini_get("eaccelerator.enable") || (bool) ini_get("xcache.cacher")) {
             message::warning(t("The eAccelerator and XCache PHP performance extensions are known to cause issues.  If you're using either of those and are having problems, please disable them while you do your import.  Add the following lines: <pre>%lines</pre> to gallery3/.htaccess and remove them when the import is done.", array("lines" => "\n\n  php_value eaccelerator.enable 0\n  php_value xcache.cacher off\n  php_value xcache.optimizer off\n\n")));
         }
         foreach (array("notification", "search", "exif") as $module_id) {
             if (module::is_active($module_id)) {
                 message::warning(t("<a href=\"%url\">Deactivating</a> the <b>%module_id</b> module during your import will make it faster", array("url" => url::site("admin/modules"), "module_id" => $module_id)));
             }
         }
         if (module::is_active("akismet")) {
             message::warning(t("The Akismet module may mark some or all of your imported comments as spam.  <a href=\"%url\">Deactivate</a> it to avoid that outcome.", array("url" => url::site("admin/modules"))));
         }
     } else {
         if (g2_import::is_configured()) {
             $view->content->form->configure_g2_import->embed_path->add_error("invalid", 1);
         }
     }
     g2_import::restore_error_reporting();
     print $view;
 }
Esempio n. 9
0
 /**
  * Attempts to load a view and pre-load view data.
  *
  * @throws  Kohana_Exception  if the requested view cannot be found
  * @param   string  $name view name
  * @param   string  $page_type page type: collection, item, or other
  * @param   string  $page_subtype page sub type: album, photo, tags, etc
  * @param   string  $theme_name view name
  * @return  void
  */
 public function __construct($name, $page_type, $page_subtype)
 {
     parent::__construct($name);
     $this->theme_name = module::get_var("gallery", "active_site_theme");
     if (identity::active_user()->admin) {
         $this->theme_name = Input::instance()->get("theme", $this->theme_name);
     }
     $this->item = null;
     $this->tag = null;
     $this->set_global(array("theme" => $this, "user" => identity::active_user(), "page_type" => $page_type, "page_subtype" => $page_subtype, "page_title" => null));
     if ($page_type == "collection") {
         $this->set_global("thumb_proportion", $this->thumb_proportion());
     }
     if (module::get_var("gallery", "maintenance_mode", 0)) {
         if (identity::active_user()->admin) {
             message::warning(t("This site is currently in maintenance mode.  Visit the <a href=\"%maintenance_url\">maintenance page</a>", array("maintenance_url" => url::site("admin/maintenance"))));
         } else {
             message::warning(t("This site is currently in maintenance mode."));
         }
     }
 }
Esempio n. 10
0
 /**
  * Attempts to load a view and pre-load view data.
  *
  * @throws  Kohana_Exception  if the requested view cannot be found
  * @param   string  $name view name
  * @param   string  $page_type page type: collection, item, or other
  * @param   string  $page_subtype page sub type: album, photo, tags, etc
  * @param   string  $theme_name view name
  * @return  void
  */
 public function __construct($name, $page_type, $page_subtype)
 {
     parent::__construct($name);
     $this->theme_name = module::get_var("gallery", "active_site_theme");
     if (identity::active_user()->admin) {
         $theme_name = Input::instance()->get("theme");
         if ($theme_name && file_exists(THEMEPATH . $theme_name) && strpos(realpath(THEMEPATH . $theme_name), THEMEPATH) == 0) {
             $this->theme_name = $theme_name;
         }
     }
     $this->item = null;
     $this->tag = null;
     $this->set_global(array("theme" => $this, "theme_info" => theme::get_info($this->theme_name), "user" => identity::active_user(), "page_type" => $page_type, "page_subtype" => $page_subtype, "page_title" => null));
     if (module::get_var("gallery", "maintenance_mode", 0)) {
         if (identity::active_user()->admin) {
             message::warning(t("This site is currently in maintenance mode.  Visit the <a href=\"%maintenance_url\">maintenance page</a>", array("maintenance_url" => url::site("admin/maintenance"))));
         } else {
             message::warning(t("This site is currently in maintenance mode."));
         }
     }
 }
 public function index()
 {
     if (g1_import::is_configured()) {
         g1_import::init();
     }
     $view = new Admin_View('admin.html');
     $view->page_title = t('Gallery 1 import');
     $view->content = new View('admin_g1_import.html');
     if (is_dir(g1_import::$album_dir)) {
         $view->content->g1_stats = $g1_stats = g1_import::g1_stats();
         $view->content->g3_stats = $g3_stats = g1_import::g3_stats();
         $view->content->g1_sizes = g1_import::common_sizes();
         $view->content->g1_version = g1_import::version();
         // Don't count tags because we don't track them in g1_map
         $view->content->g1_resource_count = $g1_stats['users'] + $g1_stats['groups'] + $g1_stats['albums'] + $g1_stats['photos'] + $g1_stats['movies'] + $g1_stats['comments'];
         $view->content->g3_resource_count = $g3_stats['user'] + $g3_stats['group'] + $g3_stats['album'] + $g3_stats['item'] + $g3_stats['comment'] + $g3_stats['tag'];
     }
     $view->content->form = $this->_get_import_form();
     $view->content->version = '';
     $view->content->thumb_size = module::get_var('gallery', 'thumb_size');
     $view->content->resize_size = module::get_var('gallery', 'resize_size');
     if (g1_import::is_initialized()) {
         if (count(g1_import::$warn_utf8) > 0) {
             message::error(t('Your G1 contains %count folder(s) containing nonstandard characters that G3 doesn\'t work with: <pre>%names</pre>Please rename the above folders in G1 before trying to import your data.', array('count' => count(g1_import::$warn_utf8), 'names' => "\n\n  " . implode("\n  ", g1_import::$warn_utf8) . "\n\n")));
         }
         if ((bool) ini_get('eaccelerator.enable') || (bool) ini_get('xcache.cacher')) {
             message::warning(t('The eAccelerator and XCache PHP performance extensions are known to cause issues.  If you\'re using either of those and are having problems, please disable them while you do your import.  Add the following lines: <pre>%lines</pre> to gallery3/.htaccess and remove them when the import is done.', array('lines' => "\n\n  php_value eaccelerator.enable 0\n  php_value xcache.cacher off\n  php_value xcache.optimizer off\n\n")));
         }
         foreach (array('notification', 'search', 'exif') as $module_id) {
             if (module::is_active($module_id)) {
                 message::warning(t('<a href="%url">Deactivating</a> the <b>%module_id</b> module during your import will make it faster', array('url' => url::site('admin/modules'), 'module_id' => $module_id)));
             }
         }
     } else {
         if (g1_import::is_configured()) {
             $view->content->form->configure_g1_import->albums_path->add_error('invalid', 1);
         }
     }
     print $view;
 }
Esempio n. 12
0
 /**
  * Attempts to load a view and pre-load view data.
  *
  * @throws  Kohana_Exception  if the requested view cannot be found
  * @param   string  $name view name
  * @param   string  $page_type page type: collection, item, or other
  * @param   string  $page_subtype page sub type: album, photo, tags, etc
  * @param   string  $theme_name view name
  * @return  void
  */
 public function __construct($name, $page_type, $page_subtype)
 {
     parent::__construct($name);
     $this->theme_name = module::get_var("gallery", "active_site_theme");
     if (identity::active_user()->admin) {
         $this->theme_name = Input::instance()->get("theme", $this->theme_name);
     }
     $this->item = null;
     $this->tag = null;
     $this->set_global("theme", $this);
     $this->set_global("user", identity::active_user());
     $this->set_global("page_type", $page_type);
     $this->set_global("page_subtype", $page_subtype);
     $this->set_global("page_title", null);
     if ($page_type == "collection") {
         $this->set_global("thumb_proportion", $this->thumb_proportion());
     }
     $maintenance_mode = Kohana::config("core.maintenance_mode", false, false);
     if ($maintenance_mode) {
         message::warning(t("This site is currently in maintenance mode"));
     }
 }
 public function save()
 {
     site_status::clear("gd_init_configuration");
     access::verify_csrf();
     $form = self::get_edit_form_admin();
     if ($form->validate()) {
         module::clear_var("th_greydragon", "photonav_top");
         module::clear_var("th_greydragon", "photonav_bottom");
         module::clear_var("th_greydragon", "hide_sidebar_photo");
         module::clear_var("th_greydragon", "hide_thumbdesc");
         module::clear_var("th_greydragon", "use_detailview");
         if ($form->maintenance->reset_theme->value) {
             module::set_var("gallery", "page_size", 9);
             module::set_var("gallery", "resize_size", 640);
             module::set_var("gallery", "thumb_size", 200);
             module::set_var("gallery", "header_text", "");
             module::set_var("gallery", "footer_text", "");
             module::clear_var("th_greydragon", "copyright");
             module::clear_var("th_greydragon", "logo_path");
             module::clear_var("th_greydragon", "color_pack");
             module::clear_var("th_greydragon", "enable_pagecache");
             module::set_var("gallery", "show_credits", FALSE);
             module::clear_var("th_greydragon", "show_guest_menu");
             module::clear_var("th_greydragon", "mainmenu_position");
             module::clear_var("th_greydragon", "loginmenu_position");
             module::clear_var("th_greydragon", "hide_breadcrumbs");
             module::clear_var("th_greydragon", "horizontal_crop");
             module::clear_var("th_greydragon", "thumb_descmode");
             module::clear_var("th_greydragon", "hide_thumbmeta");
             module::clear_var("th_greydragon", "hide_blockheader");
             module::clear_var("th_greydragon", "photonav_position");
             module::clear_var("th_greydragon", "photo_descmode");
             module::clear_var("th_greydragon", "desc_allowbbcode");
             module::clear_var("th_greydragon", "hide_photometa");
             module::clear_var("th_greydragon", "disable_seosupport");
             module::clear_var("th_greydragon", "sidebar_albumonly");
             module::clear_var("th_greydragon", "sidebar_allowed");
             module::clear_var("th_greydragon", "sidebar_visible");
             module::event("theme_edit_form_completed", $form);
             message::success(t("Theme details are reset"));
         } else {
             // * General Settings ****************************************************
             $_priorratio = module::get_var("th_greydragon", "thumb_ratio");
             if (!$_priorratio) {
                 $_priorratio = "digital";
             }
             $resize_size = $form->edit_theme->resize_size->value;
             $thumb_size = 200;
             $build_resize = $form->maintenance->build_resize->value;
             $build_thumbs = $form->maintenance->build_thumbs->value;
             $build_exif = $form->maintenance->build_exif->value;
             $thumb_ratio = $form->edit_theme_adv_thumb->thumb_ratio->value;
             if ($thumb_ratio == "photo") {
                 $rule = Image::AUTO;
             } else {
                 $rule = Image::WIDTH;
             }
             $color_pack = $form->edit_theme->colorpack->value;
             $thumb_descmode = $form->edit_theme_adv_thumb->thumb_descmode->value;
             $photo_descmode = $form->edit_theme_adv_photo->photo_descmode->value;
             if ($build_resize) {
                 graphics::remove_rule("gallery", "resize", "gallery_graphics::resize");
                 graphics::add_rule("gallery", "resize", "gallery_graphics::resize", array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO), 100);
             }
             if (module::get_var("gallery", "resize_size") != $resize_size) {
                 module::set_var("gallery", "resize_size", $resize_size);
             }
             if ($build_thumbs) {
                 graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize");
                 graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", array("width" => $thumb_size, "height" => $thumb_size, "master" => $rule), 100);
             }
             if ($build_exif) {
                 db::build()->delete("exif_records")->execute();
             }
             if (module::get_var("gallery", "thumb_size") != $thumb_size) {
                 module::set_var("gallery", "thumb_size", $thumb_size);
             }
             module::set_var("gallery", "header_text", $form->edit_theme->header_text->value);
             module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value);
             $this->save_item_state("copyright", $form->edit_theme->copyright->value, $form->edit_theme->copyright->value);
             $this->save_item_state("logo_path", $form->edit_theme->logo_path->value, $form->edit_theme->logo_path->value);
             $this->save_item_state("color_pack", $color_pack and $color_pack != "greydragon", $color_pack);
             // * Advanced Options - main *********************************************
             module::set_var("gallery", "show_credits", $form->edit_theme_adv_main->show_credits->value);
             $this->save_item_state("show_guest_menu", $form->edit_theme_adv_main->show_guest_menu->value, TRUE);
             $this->save_item_state("loginmenu_position", $form->edit_theme_adv_main->loginmenu_position->value == "1", "header");
             $this->save_item_state("mainmenu_position", $form->edit_theme_adv_main->mainmenu_position->value == "1", "top");
             $this->save_item_state("hide_breadcrumbs", $form->edit_theme_adv_main->hide_breadcrumbs->value, TRUE);
             $this->save_item_state("photonav_position", $form->edit_theme_adv_main->photonav_position->value != "top", $form->edit_theme_adv->photonav_position->value);
             $this->save_item_state("enable_pagecache", $form->edit_theme_adv_main->enable_pagecache->value, TRUE);
             $this->save_item_state("disable_seosupport", $form->edit_theme_adv_main->disable_seosupport->value, TRUE);
             // * Advanced Options - Album page ***************************************
             $this->save_item_state("thumb_ratio", $thumb_ratio != "photo", $thumb_ratio);
             $this->save_item_state("thumb_descmode", $thumb_descmode != "overlay", $thumb_descmode);
             $this->save_item_state("hide_thumbmeta", $form->edit_theme_adv_thumb->hide_thumbmeta->value, TRUE);
             // * Advanced Options - Photo page ***************************************
             $this->save_item_state("photo_descmode", $photo_descmode != "overlay", $photo_descmode);
             $this->save_item_state("desc_allowbbcode", $form->edit_theme_adv_photo->desc_allowbbcode->value, TRUE);
             $this->save_item_state("hide_photometa", !$form->edit_theme_adv_photo->hide_photometa->value, FALSE);
             // * Sidebar Options ****************************************************
             $sidebar_allowed = $form->edit_theme_side->sidebar_allowed->value;
             $sidebar_visible = $form->edit_theme_side->sidebar_visible->value;
             if ($sidebar_allowed == "right") {
                 $sidebar_visible = "right";
             }
             if ($sidebar_allowed == "left") {
                 $sidebar_visible = "left";
             }
             $this->save_item_state("hide_blockheader", $form->edit_theme_side->hide_blockheader->value, TRUE);
             $this->save_item_state("sidebar_albumonly", $form->edit_theme_side->sidebar_albumonly->value, TRUE);
             $this->save_item_state("sidebar_allowed", $sidebar_allowed != "any", $sidebar_allowed);
             $this->save_item_state("sidebar_visible", $sidebar_visible != "right", $sidebar_visible);
             if ($sidebar_allowed == "none" and $sidebar_visible == "none") {
                 module::set_var("gallery", "page_size", $form->edit_theme->row_count->value * 4);
             } else {
                 module::set_var("gallery", "page_size", $form->edit_theme->row_count->value * 3);
             }
             module::event("theme_edit_form_completed", $form);
             if ($_priorratio != $thumb_ratio) {
                 message::warning(t("Thumb aspect ratio has been changed. Consider rebuilding thumbs if needed."));
             }
             message::success(t("Updated theme details"));
         }
         url::redirect("admin/theme_options");
     } else {
         $view = new Admin_View("admin.html");
         $view->content = $form;
         print $view;
     }
 }
Esempio n. 14
0
 static function log($msg)
 {
     message::warning($msg);
     Kohana::log("alert", $msg);
 }
Esempio n. 15
0
 static function log($msg)
 {
     message::warning($msg);
     Kohana_Log::add("alert", $msg);
 }
Esempio n. 16
0
 public function pause($id, $task_id)
 {
     access::verify_csrf();
     $task = ORM::factory("task", $task_id);
     message::warning(t("Add from server was cancelled prior to completion"));
     batch::stop();
     print json_encode(array("result" => "success"));
 }
Esempio n. 17
0
 static function site_menu($menu, $theme, $item_css_selector)
 {
     if ($theme->page_subtype != "login") {
         $menu->append(Menu::factory("link")->id("home")->label(t("Home"))->url(item::root()->url()));
         $item = $theme->item();
         if (!empty($item)) {
             $can_edit = $item && access::can("edit", $item);
             $can_add = $item && access::can("add", $item);
             if ($can_add) {
                 $menu->append($add_menu = Menu::factory("submenu")->id("add_menu")->label(t("Add")));
                 $is_album_writable = is_writable($item->is_album() ? $item->file_path() : $item->parent()->file_path());
                 if ($is_album_writable) {
                     $add_menu->append(Menu::factory("dialog")->id("add_photos_item")->label(t("Add photos"))->url(url::site("uploader/index/{$item->id}")));
                     if ($item->is_album()) {
                         $add_menu->append(Menu::factory("dialog")->id("add_album_item")->label(t("Add an album"))->url(url::site("form/add/albums/{$item->id}?type=album")));
                     }
                 } else {
                     message::warning(t("The album '%album_name' is not writable.", array("album_name" => $item->title)));
                 }
             }
             switch ($item->type) {
                 case "album":
                     $option_text = t("Album options");
                     $edit_text = t("Edit album");
                     $delete_text = t("Delete album");
                     break;
                 case "movie":
                     $option_text = t("Movie options");
                     $edit_text = t("Edit movie");
                     $delete_text = t("Delete movie");
                     break;
                 default:
                     $option_text = t("Photo options");
                     $edit_text = t("Edit photo");
                     $delete_text = t("Delete photo");
             }
             $menu->append($options_menu = Menu::factory("submenu")->id("options_menu")->label($option_text));
             if ($item && ($can_edit || $can_add)) {
                 if ($can_edit) {
                     $options_menu->append(Menu::factory("dialog")->id("edit_item")->label($edit_text)->url(url::site("form/edit/{$item->type}s/{$item->id}?from_id={$item->id}")));
                 }
                 if ($item->is_album()) {
                     if ($can_edit) {
                         $options_menu->append(Menu::factory("dialog")->id("edit_permissions")->label(t("Edit permissions"))->url(url::site("permissions/browse/{$item->id}")));
                     }
                 }
             }
             $csrf = access::csrf_token();
             $page_type = $theme->page_type();
             if ($can_edit && $item->is_photo() && graphics::can("rotate")) {
                 $options_menu->append(Menu::factory("ajax_link")->id("rotate_ccw")->label(t("Rotate 90° counter clockwise"))->css_class("ui-icon-rotate-ccw")->ajax_handler("function(data) { " . "\$.gallery_replace_image(data, \$('{$item_css_selector}')) }")->url(url::site("quick/rotate/{$item->id}/ccw?csrf={$csrf}&amp;from_id={$item->id}&amp;page_type={$page_type}")))->append(Menu::factory("ajax_link")->id("rotate_cw")->label(t("Rotate 90° clockwise"))->css_class("ui-icon-rotate-cw")->ajax_handler("function(data) { " . "\$.gallery_replace_image(data, \$('{$item_css_selector}')) }")->url(url::site("quick/rotate/{$item->id}/cw?csrf={$csrf}&amp;from_id={$item->id}&amp;page_type={$page_type}")));
             }
             if ($item->id != item::root()->id) {
                 $parent = $item->parent();
                 if (access::can("edit", $parent)) {
                     // We can't make this item the highlight if it's an album with no album cover, or if it's
                     // already the album cover.
                     if ($item->type == "album" && empty($item->album_cover_item_id) || $item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id || $parent->album_cover_item_id == $item->id) {
                         $disabledState = "ui-state-disabled";
                     } else {
                         $disabledState = "";
                     }
                     if ($item->parent()->id != 1) {
                         $options_menu->append(Menu::factory("ajax_link")->id("make_album_cover")->label(t("Choose as the album cover"))->css_class("ui-icon-star {$disabledState}")->ajax_handler("function(data) { window.location.reload() }")->url(url::site("quick/make_album_cover/{$item->id}?csrf={$csrf}")));
                     }
                     $options_menu->append(Menu::factory("dialog")->id("delete")->label($delete_text)->css_class("ui-icon-trash")->css_class("g-quick-delete")->url(url::site("quick/form_delete/{$item->id}?csrf={$csrf}&amp;from_id={$item->id}&amp;page_type={$page_type}")));
                 }
             }
         }
         if (identity::active_user()->admin) {
             $menu->append($admin_menu = Menu::factory("submenu")->id("admin_menu")->label(t("Admin")));
             module::event("admin_menu", $admin_menu, $theme);
             $settings_menu = $admin_menu->get("settings_menu");
             uasort($settings_menu->elements, array("Menu", "title_comparator"));
         }
     }
 }
Esempio n. 18
0
 private function _do_save()
 {
     $changes = new stdClass();
     $changes->activate = array();
     $changes->deactivate = array();
     $activated_names = array();
     $deactivated_names = array();
     foreach (module::available() as $module_name => $info) {
         if ($info->locked) {
             continue;
         }
         try {
             $desired = Input::instance()->post($module_name) == 1;
             if ($info->active && !$desired && module::is_active($module_name)) {
                 module::deactivate($module_name);
                 $changes->deactivate[] = $module_name;
                 $deactivated_names[] = t($info->name);
             } else {
                 if (!$info->active && $desired && !module::is_active($module_name)) {
                     if (module::is_installed($module_name)) {
                         module::upgrade($module_name);
                     } else {
                         module::install($module_name);
                     }
                     module::activate($module_name);
                     $changes->activate[] = $module_name;
                     $activated_names[] = t($info->name);
                 }
             }
         } catch (Exception $e) {
             message::warning(t("An error occurred while installing the <b>%module_name</b> module", array("module_name" => $info->name)));
             Kohana_Log::add("error", (string) $e);
         }
     }
     module::event("module_change", $changes);
     // @todo this type of collation is questionable from an i18n perspective
     if ($activated_names) {
         message::success(t("Activated: %names", array("names" => join(", ", $activated_names))));
     }
     if ($deactivated_names) {
         message::success(t("Deactivated: %names", array("names" => join(", ", $deactivated_names))));
     }
 }
 function mptt()
 {
     $v = new Admin_View("admin.html");
     $v->content = new View("mptt_tree.html");
     $v->content->tree = $this->_build_tree();
     if (exec("which /usr/bin/dot")) {
         $v->content->url = url::site("admin/developer/mptt_graph");
     } else {
         $v->content->url = null;
         message::warning(t("The package 'graphviz' is not installed, degrading to text view"));
     }
     print $v;
 }
Esempio n. 20
0
 public function pause($id, $task_id)
 {
     if (!user::active()->admin) {
         access::forbidden();
     }
     access::verify_csrf();
     $task = ORM::factory("task", $task_id);
     if (!$task->loaded || $task->owner_id != user::active()->id) {
         access::forbidden();
     }
     message::warning(t("Add from server was cancelled prior to completion"));
     batch::stop();
     print json_encode(array("result" => "success"));
 }
Esempio n. 21
0
 /**
  * Import a single photo or movie.
  */
 static function import_item(&$queue)
 {
     $g2_item_id = array_shift($queue);
     if (self::map($g2_item_id)) {
         return;
     }
     self::$current_g2_item = $g2_item = g2(GalleryCoreApi::loadEntitiesById($g2_item_id));
     $parent = ORM::factory("item", self::map($g2_item->getParentId()));
     $g2_path = g2($g2_item->fetchPath());
     $g2_type = $g2_item->getEntityType();
     $corrupt = 0;
     if (!file_exists($g2_path)) {
         // If the Gallery2 source image isn't available, this operation is going to fail.  That can
         // happen in cases where there's corruption in the source Gallery 2.  In that case, fall
         // back on using a broken image.  It's important that we import *something* otherwise
         // anything that refers to this item in Gallery 2 will have a dangling pointer in Gallery 3
         //
         // Note that this will change movies to be photos, if there's a broken movie.  Hopefully
         // this case is rare enough that we don't need to take any heroic action here.
         Kohana::log("alert", "{$g2_path} missing in import; replacing it");
         $g2_path = MODPATH . "g2_import/data/broken-image.gif";
         $g2_type = "GalleryPhotoItem";
         $corrupt = 1;
     }
     switch ($g2_type) {
         case "GalleryPhotoItem":
             if (!in_array($g2_item->getMimeType(), array("image/jpeg", "image/gif", "image/png"))) {
                 $g2_path = MODPATH . "g2_import/data/broken-image.gif";
                 Kohana::log("alert", "{$g2_path} unsupported image type; using a placeholder gif");
                 $corrupt = 1;
             }
             $item = photo::create($parent, $g2_path, $g2_item->getPathComponent(), $g2_item->getTitle(), self::extract_description($g2_item), self::map($g2_item->getOwnerId()));
             break;
         case "GalleryMovieItem":
             // @todo we should transcode other types into FLV
             if (in_array($g2_item->getMimeType(), array("video/mp4", "video/x-flv"))) {
                 $item = movie::create($parent, $g2_path, $g2_item->getPathComponent(), $g2_item->getTitle(), self::extract_description($g2_item), self::map($g2_item->getOwnerId()));
             }
             break;
         default:
             // Ignore
             break;
     }
     if (!empty($item)) {
         self::import_keywords_as_tags($g2_item->getKeywords(), $item);
     }
     if (isset($item)) {
         self::set_map($g2_item_id, $item->id);
     }
     if ($corrupt) {
         $url_generator = $GLOBALS["gallery"]->getUrlGenerator();
         // @todo we need a more persistent warning
         $g2_item_url = $url_generator->generateUrl(array("itemId" => $g2_item->getId()));
         // Why oh why did I ever approve the session id placeholder idea in G2?
         $g2_item_url = str_replace('&amp;g2_GALLERYSID=TMP_SESSION_ID_DI_NOISSES_PMT', '', $g2_item_url);
         $warning = t("<a href=\"%g2_url\">%title</a> from Gallery 2 could not be processed; " . "(imported as <a href=\"%g3_url\">%title</a>)", array("g2_url" => $g2_item_url, "g3_url" => $item->url(), "title" => $g2_item->getTitle()));
         message::warning($warning);
         log::warning("g2_import", $warning);
         Kohana::log("alert", $warning);
     }
     self::$current_g2_item = null;
 }
Esempio n. 22
0
if (dyn::get('user')->hasPerm('admin[addon]')) {
    backend::addNavi(lang::get('addons'), url::backend('addons'), 'code-fork');
}
if (dyn::get('user')->isAdmin()) {
    backend::addNavi(lang::get('settings'), url::backend('settings'), 'cogs');
}
$failed_plugins = 0;
foreach (addonConfig::includeAllConfig() as $file) {
    if (file_exists($file)) {
        require_once $file;
    } else {
        $failed_plugins++;
    }
}
if ($failed_plugins > 0) {
    echo message::warning(lang::get('failed_plugins_load'));
}
$page = type::super('page', 'string', 'dashboard');
$subpage = type::super('subpage', 'string');
$successMsg = type::get('success_msg', 'string');
$errorMsg = type::get('error_msg', 'string');
if (!is_null($errorMsg)) {
    echo message::danger($errorMsg);
} elseif (!is_null($successMsg)) {
    echo message::success($successMsg);
}
if (userLogin::isLogged()) {
    if ($file = backend::getNaviInclude()) {
        include $file;
    }
}
Esempio n. 23
0
			</div>
			<div class="panel-body">
				<?php 
    echo $form->show();
    ?>
			</div>
		</div>
	</div>
</div>
<?php 
}
if ($action == '') {
    $sql = sql::factory();
    $cats = $sql->num('SELECT id FROM ' . sql::table('media_cat') . ' LIMIT 1');
    if (!$cats) {
        echo message::warning('Please add at first a Category');
        return;
    }
    if (!$catId) {
        $catId = type::session('media_cat', 'int', $catId);
    }
    if (!$catId) {
        $sql = sql::factory();
        $sql->query('SELECT id FROM ' . sql::table('media_cat') . ' ORDER BY id LIMIT 1')->result();
        $catId = $sql->get('id');
    }
    type::addSession('media_cat', $catId);
    $table = table::factory(['class' => ['media-table']]);
    $table->setSql('SELECT * FROM ' . sql::table('media') . ' WHERE `category` = ' . $catId);
    $table->addRow()->addCell()->addCell()->addCell(lang::get('title'))->addCell(lang::get('file_type'))->addCell(lang::get('action'));
    $table->addCollsLayout('20, 50,*,100,110');
Esempio n. 24
0
 public function first($hash)
 {
     $pending_user = ORM::factory("pending_user")->where("hash", "=", $hash)->where("state", "=", 2)->find();
     if ($pending_user->loaded()) {
         // @todo add a request date to the pending user table and check that it hasn't expired
         $user = identity::lookup_user_by_name($pending_user->name);
         if (!empty($user)) {
             auth::login($user);
             Session::instance()->set("registration_first_usage", true);
             $pending_user->delete();
         }
         url::redirect(item::root()->abs_url());
     } else {
         message::warning(t("Your account is ready to use so please login."));
     }
     url::redirect(item::root()->abs_url());
 }