/**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch our data
     $this->_albumName = Textfilter::filterAllHTML($this->_request->getValue("albumName"));
     $this->_albumDescription = Textfilter::filterAllHTML($this->_request->getValue("albumDescription"));
     $this->_parentId = $this->_request->getValue("parentId");
     $showAlbum = $this->_request->getValue("showAlbum") ? 1 : 0;
     // create the album
     $albums = new GalleryAlbums();
     $t = new Timestamp();
     $album = new GalleryAlbum($this->_blogInfo->getId(), $this->_albumName, $this->_albumDescription, GALLERY_RESOURCE_PREVIEW_AVAILABLE, $this->_parentId, $t->getTimestamp(), array(), $showAlbum);
     $this->notifyEvent(EVENT_PRE_ALBUM_ADD, array("album" => &$album));
     // and add it to the database
     $result = $albums->addAlbum($album);
     $this->_view = new AdminResourcesListView($this->_blogInfo, array("albumId" => $this->_parentId));
     if ($result) {
         $this->_view->setSuccessMessage($this->_locale->pr("album_added_ok", $album->getName()));
         $this->notifyEvent(EVENT_POST_ALBUM_ADD, array("album" => &$album));
         // clear the cache if everything went fine
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     } else {
         $this->_view->setErrorMessage($this->_locale->tr("error_adding_album"));
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 function render()
 {
     // load the nested list of albums
     $albums = new GalleryAlbums();
     $userAlbums = $albums->getNestedAlbumList($this->_blogInfo->getId());
     $this->notifyEvent(EVENT_ALBUMS_LOADED, array("albums" => &$userAlbums));
     $this->setValue("albums", $userAlbums);
     // let the parent view do its work
     parent::render();
 }
 function render()
 {
     // get all the albums
     $albums = new GalleryAlbums();
     $userAlbums = $albums->getNestedAlbumList($this->_blogInfo->getId());
     $this->notifyEvent(EVENT_ALBUMS_LOADED, array("albums" => &$userAlbums));
     $this->setValue("albums", $userAlbums);
     // transfer control to the parent class
     parent::render();
 }
 function render()
 {
     // load the nested list of albums
     // fetch the albums for this blog
     $albums = new GalleryAlbums();
     $blogAlbums = $albums->getNestedAlbumList($this->_blogInfo->getId());
     $this->notifyEvent(EVENT_ALBUMS_LOADED, array("albums" => &$blogAlbums));
     $this->setValue("albums", $blogAlbums);
     parent::render();
 }
 function perform()
 {
     $galleryResources = new GalleryResources();
     $galleryAlbums = new GalleryAlbums();
     // initialize the view
     $this->_view = new BlogView($this->_blogInfo, VIEW_RESOURCE_TEMPLATE, SMARTY_VIEW_CACHE_CHECK, array("resourceId" => $this->_resourceId, "resourceName" => $this->_resourceName, "albumName" => $this->_albumName, "albumId" => $this->_albumId));
     // if it's cached, do nothing
     if ($this->_view->isCached()) {
         return true;
     }
     // otherwise continue as normal...
     // try to find the album to which this resource belongs
     if ($this->_albumName) {
         $album = $galleryAlbums->getAlbumByName($this->_albumName, $this->_blogInfo->getId(), false, false);
         if (!$album) {
             $this->_view = new ErrorView($this->_blogInfo);
             $this->_view->setValue("message", "error_fetching_resource");
             $this->setCommonData();
             return false;
         }
         $this->_albumId = $album->getId();
     }
     // fetch the album we're trying to browse
     if ($this->_resourceName != "") {
         $resource = $galleryResources->getResourceFile($this->_blogInfo->getId(), $this->_resourceName, $this->_albumId);
     } else {
         $resource = $galleryResources->getResource($this->_resourceId, $this->_blogInfo->getId(), $this->_albumId);
     }
     // check if the album was correctly fetched
     if (!$resource) {
         $this->_view = new ErrorView($this->_blogInfo);
         $this->_view->setValue("message", "error_fetching_resource");
         $this->setCommonData();
         return false;
     }
     // if all went fine, continue loading the next and previous resources so that
     // navigation can be made easier...
     $nextResource = $galleryResources->getNextResource($resource);
     $prevResource = $galleryResources->getPreviousResource($resource);
     // generate events for all the resources we just loaded
     $this->notifyEvent(EVENT_RESOURCE_LOADED, array("resource" => &$resource));
     if ($nextResource) {
         $this->notifyEvent(EVENT_RESOURCE_LOADED, array("resource" => &$nextResource));
     }
     if ($prevResource) {
         $this->notifyEvent(EVENT_RESOURCE_LOADED, array("resource" => &$prevResource));
     }
     $this->_view->setValue("resource", $resource);
     $this->_view->setValue("prevresource", $prevResource);
     $this->_view->setValue("nextresource", $nextResource);
     $this->setCommonData();
     // and return everything normal
     return true;
 }
 /**
  * returns a nicely formated string with <option>...</option> tags that can be
  * used in a <select> list. It will nest the album names in order to graphically
  * describe hierarchies, for easier understanding of how our album structure
  * is built
  *
  * @param userId
  * @return A string
  */
 function getNestedDropDownListContents($userId)
 {
     // fetch the list of albums properly arranged
     $albums = new GalleryAlbums();
     $userAlbums = $albums->getUserAlbumsGroupedByParentId($userId);
     // printing format
     $format = '<option value="{id}">{name}</option>';
     // call the method and return the results
     $result = GalleryTemplateTools::_printNested($userAlbums, $format, "&nbsp;&nbsp;&nbsp;");
     return $result;
 }
 function perform()
 {
     $galleryResources = new GalleryResources();
     $galleryAlbums = new GalleryAlbums();
     $browseRootAlbum = $this->_albumId == 0 && $this->_albumName == "";
     // check which template we should use
     if ($browseRootAlbum) {
         $template = VIEW_ALBUMS_TEMPLATE;
     } else {
         $template = VIEW_ALBUM_TEMPLATE;
     }
     // initialize the view and check if it was cached
     $this->_view = new BlogView($this->_blogInfo, $template, SMARTY_VIEW_CACHE_CHECK, array("albumId" => $this->_albumId, "albumName" => $this->_albumName));
     if ($this->_view->isCached()) {
         // nothing to do if it is cached!
         return true;
     }
     // fetch the album we're trying to browse
     if ($browseRootAlbum) {
         // fetch only the first level albums
         $blogAlbums = $galleryAlbums->getChildAlbums(0, $this->_blogInfo->getId(), true);
         if (count($blogAlbums) == 0) {
             $this->_view = new ErrorView($this->_blogInfo);
             $this->_view->setValue("message", "error_no_albums_defined");
         } else {
             $this->notifyEvent(EVENT_ALBUMS_LOADED, array("albums" => &$blogAlbums));
             $this->_view->setValue("albums", $blogAlbums);
         }
     } else {
         // the third parameter is telling _not_ to fetch all those albums that have
         // been disabled and are not to be shown in the page when browsing the album
         if ($this->_albumName) {
             $album = $galleryAlbums->getAlbumByName($this->_albumName, $this->_blogInfo->getId(), true, true);
         } else {
             $album = $galleryAlbums->getAlbum($this->_albumId, $this->_blogInfo->getId(), true, true);
         }
         // check if the album was correctly fetched
         if (!$album) {
             $this->_view = new ErrorView($this->_blogInfo);
             $this->_view->setValue("message", "error_fetching_album");
             $this->setCommonData();
             return false;
         }
         $this->notifyEvent(EVENT_ALBUM_LOADED, array("album" => &$blogAlbum));
         // put the album to the template
         $this->_view->setValue("album", $album);
     }
     // if all went fine, continue
     $this->setCommonData();
     // and return everything normal
     return true;
 }
 function render()
 {
     // get the page from the request
     $this->_page = $this->getCurrentPageFromRequest();
     // and the current album
     $galleryAlbums = new GalleryAlbums();
     $galleryResources = new GalleryResources();
     if ($this->_albumId > ROOT_ALBUM_ID && $this->_page > 0) {
         $album = $galleryAlbums->getAlbum($this->_albumId, $this->_blogInfo->getId());
         if (!$album || $album == "") {
             $this->_albumId = ROOT_ALBUM_ID;
         } else {
             //$resources = $album->getResources();
             $resources = $galleryResources->getUserResources($this->_blogInfo->getId(), $this->_albumId, $this->_resourceType, $this->_page, DEFAULT_ITEMS_PER_PAGE);
             $numResources = $galleryResources->getNumUserResources($this->_blogInfo->getId(), $this->_albumId, $this->_resourceType);
         }
     } else {
         $albums = $galleryAlbums->getChildAlbums($this->_albumId, $this->_blogInfo->getId());
         $resources = array();
     }
     // get a list with the nested albums
     $userAlbums = $galleryAlbums->getNestedAlbumList($this->_blogInfo->getId());
     // event about the albums we just loaded
     $this->notifyEvent(EVENT_ALBUMS_LOADED, array("albums" => &$userAlbums));
     $this->setValue("albumsList", $userAlbums);
     // fetch some statistics and continue
     $quotaUsage = GalleryResourceQuotas::getBlogResourceQuotaUsage($this->_blogInfo->getId());
     $totalResources = $galleryResources->getNumResources($this->_blogInfo->getId());
     $currentQuota = GalleryResourceQuotas::getBlogResourceQuota($this->_blogInfo->getId());
     $this->setValue("quotausage", $quotaUsage);
     $this->setValue("totalresources", $totalResources);
     $this->setValue("quota", $currentQuota);
     // and now export info about the albums and so on but only
     // if we're browsing the first page only (albums do not appear anymore after the first page)
     $this->setValue("album", $album);
     if ($this->_albumId > ROOT_ALBUM_ID && $this->_page < 2) {
         $this->setValue("albums", $album->getChildren());
     } else {
         $this->setValue("albums", $albums);
     }
     // event about the resources
     $this->notifyEvent(EVENT_RESOURCES_LOADED, array("resources" => &$resources));
     $this->setValue("resources", $resources);
     // finally, create and export the pager
     $pager = new Pager($this->_pagerUrl, $this->_page, $numResources, DEFAULT_ITEMS_PER_PAGE);
     $this->setValue("pager", $pager);
     parent::render();
 }
 function render()
 {
     // fetch the child albums of the current top level album
     $galleryAlbums = new GalleryAlbums();
     $albums = $galleryAlbums->getChildAlbums($this->_albumId, $this->_blogInfo->getId());
     // get some info about the parent album if it's different from the
     // top level album
     if ($this->_albumId > 0) {
         $album = $galleryAlbums->getAlbum($this->_albumId, $this->_blogInfo->getId());
     }
     // fetch the albums for this blog
     $this->setValue("albums", $albums);
     $this->setValue("albumid", $this->_albumId);
     $this->setValue("album", $album);
     parent::render();
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // check that we have at least one album where to put our pictures
     $albums = new GalleryAlbums();
     if ($albums->getNumUserAlbums($this->_blogInfo->getId()) == 0) {
         $this->_view = new AdminNewAlbumView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_must_create_album_first"));
         $this->setCommonData();
         return false;
     }
     // if all's fine, continue...
     $this->_view = new AdminNewResourceView($this->_blogInfo);
     $this->setCommonData();
     $this->_view->setValue("albums", $blogAlbums);
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     $this->_albumId = $this->_request->getValue("albumId");
     $this->_parentId = $this->_request->getValue("parentId");
     $this->_albumName = Textfilter::filterAllHTML($this->_request->getValue("albumName"));
     $this->_albumDescription = Textfilter::filterAllHTML($this->_request->getValue("albumDescription"));
     $this->_showAlbum = $this->_request->getValue("showAlbum");
     if ($this->_showAlbum == "") {
         $this->_showAlbum = 0;
     }
     // fetch the albums for this blog
     $albums = new GalleryAlbums();
     $album = $albums->getAlbum($this->_albumId, $this->_blogInfo->getId());
     if (!$album) {
         $this->_view = new AdminResourcesListView($this->_blogInfo);
         $this->_blogInfo;
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_album"));
         $this->setCommonData();
         return false;
     }
     // update the fields in the object
     $album->setName($this->_albumName);
     $album->setDescription($this->_albumDescription);
     $album->setParentId($this->_parentId);
     $album->setShowAlbum($this->_showAlbum);
     $this->notifyEvent(EVENT_PRE_ALBUM_UPDATE, array("album" => &$album));
     // and update the data in the database
     if (!$albums->updateAlbum($album)) {
         $this->_view = new AdminResourcesListView($this->_blogInfo);
         $this->_blogInfo;
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_album"));
         $this->setCommonData();
         return false;
     }
     $this->_view = new AdminResourcesListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("album_updated_ok", $album->getName()));
     $this->notifyEvent(EVENT_POST_ALBUM_UPDATE, array("album" => &$album));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     // better to return true if everything fine
     return true;
 }
 /**
  * carries out the specified album
  */
 function perform()
 {
     // get the album id
     $albumId = $this->_request->getValue("albumId");
     // load the resource
     $albums = new GalleryAlbums();
     // create the view
     $this->_view = new AdminResourcesListView($this->_blogInfo);
     // fetch the resource albumm first, to get some info about it
     $album = $albums->getAlbum($albumId, $this->_blogInfo->getId(), false);
     if (!$album) {
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_album"));
         $this->setCommonData();
         return false;
     }
     // notify of the "pre" delete event
     $this->notifyEvent(EVENT_PRE_ALBUM_DELETE, array("album" => &$album));
     //
     // this album cannot be deleted if either:
     //   1) we have resources under it
     //   2) we have child albums under it
     //
     if ($album->getNumChildren() > 0 || $album->getNumResources() > 0) {
         $this->_view->setErrorMessage($this->_locale->pr("error_album_has_children", $album->getName()));
     } else {
         // otherwise, we can go ahead and remove it
         if ($albums->deleteAlbum($albumId, $this->_blogInfo->getId())) {
             $this->_view->setSuccessMessage($this->_locale->pr("album_deleted_ok", $album->getName()));
             $this->notifyEvent(EVENT_PRE_ALBUM_DELETE, array("album" => &$album));
             // clear the cache
             CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
         } else {
             $this->_view->setErrorMessage($this->_locale->pr("error_deleting_album", $album->getName()));
         }
     }
     // return the view
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the albums for this blog
     $this->_albumId = $this->_request->getValue("albumId");
     $albums = new GalleryAlbums();
     $album = $albums->getAlbum($this->_albumId, $this->_blogInfo->getId());
     if (!$album) {
         $this->_view = new AdminResourcesListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_album"));
     } else {
         // and put everything into the template
         $this->_view = new AdminEditResourceAlbumView($this->_blogInfo);
         $this->_view->setValue("albumName", $album->getName());
         $this->_view->setValue("albumDescription", $album->getDescription());
         $this->_view->setValue("showAlbum", $album->getShowAlbum());
         $this->_view->setValue("parentId", $album->getParentId());
         $this->_view->setValue("albumId", $album->getId());
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 function render()
 {
     // fetch the current settings
     $blogSettings = $this->_blogInfo->getSettings();
     $pluginEnabled = $blogSettings->getValue("plugin_moblog_enabled");
     $categoryId = $blogSettings->getValue("plugin_moblog_article_category_id");
     $albumId = $blogSettings->getValue("plugin_moblog_gallery_resource_album_id");
     $resourcePreviewType = $blogSettings->getValue("plugin_moblog_resource_preview_type");
     // fetch all the current article categories
     $categories = new ArticleCategories();
     $blogCategories = $categories->getBlogCategories($this->_blogInfo->getId());
     // fetch all the current gallery albums
     $albums = new GalleryAlbums();
     $blogAlbums = $albums->getUserAlbums($this->_blogInfo->getId());
     // finally pass all these things to the templates
     $this->setValue("pluginEnabled", $pluginEnabled);
     $this->setValue("categoryId", $categoryId);
     $this->setValue("albumId", $albumId);
     $this->setValue("albums", $blogAlbums);
     $this->setValue("categories", $blogCategories);
     $this->setValue("resourcePreviewType", $resourcePreviewType);
     parent::render();
 }
    function __construct()
    {
        parent::__construct();
        global $objLogin;
        $album = MicroGrid::GetParameter('album', false);
        $objAlbums = new GalleryAlbums();
        $album_info = $objAlbums->GetAlbumInfo($album);
        $this->params = array();
        if (isset($_POST['album_code'])) {
            $this->params['album_code'] = prepare_input($_POST['album_code']);
        }
        if (isset($_POST['priority_order'])) {
            $this->params['priority_order'] = prepare_input($_POST['priority_order']);
        }
        if (isset($_POST['is_active'])) {
            $this->params['is_active'] = prepare_input($_POST['is_active']);
        } else {
            $this->params['is_active'] = '0';
        }
        if ($album_info[0]['album_type'] == 'video') {
            if (isset($_POST['item_file'])) {
                $this->params['item_file'] = prepare_input($_POST['item_file']);
                if ($this->params['item_file'] != '' && !preg_match('/^http:\\/\\/i/', $this->params['item_file'])) {
                    $this->params['item_file'] = 'http://' . $this->params['item_file'];
                }
            }
            if (isset($_POST['item_file_thumb'])) {
                $this->params['item_file_thumb'] = prepare_input($_POST['item_file_thumb'], false, 'medium');
            }
        }
        ///$this->params['language_id'] 	= MicroGrid::GetParameter('language_id');
        $icon_width = ModulesSettings::Get('gallery', 'album_icon_width') != '' ? ModulesSettings::Get('gallery', 'album_icon_width') : '120px';
        $icon_height = ModulesSettings::Get('gallery', 'album_icon_height') != '' ? ModulesSettings::Get('gallery', 'album_icon_height') : '90px';
        $this->primaryKey = 'id';
        $this->tableName = TABLE_GALLERY_ALBUM_ITEMS;
        $this->dataSet = array();
        $this->error = '';
        $this->formActionURL = 'index.php?admin=mod_gallery_upload_items&album=' . $album;
        $this->actions = array('add' => true, 'edit' => true, 'details' => true, 'delete' => true);
        $this->actionIcons = true;
        $this->allowRefresh = true;
        $this->allowTopButtons = true;
        $this->allowLanguages = false;
        $this->languageId = $objLogin->GetPreferredLang();
        $this->WHERE_CLAUSE = 'WHERE album_code = \'' . $album . '\'';
        $this->ORDER_CLAUSE = 'ORDER BY priority_order ASC';
        // ORDER BY date_created DESC
        $this->isAlterColorsAllowed = true;
        $this->isPagingAllowed = true;
        $this->pageSize = 20;
        $this->isSortingAllowed = true;
        $this->isFilteringAllowed = false;
        // define filtering fields
        $this->arrFilteringFields = array();
        ///////////////////////////////////////////////////////////////////////////////
        // 1. prepare translation fields array
        $this->arrTranslations = $this->PrepareTranslateFields(array('name', 'description'));
        ///////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////
        // 2. prepare translations array for edit/detail modes
        $sql_translation_description = $this->PrepareTranslateSql(TABLE_GALLERY_ALBUM_ITEMS_DESCRIPTION, 'gallery_album_item_id', array('name', 'description'));
        ///////////////////////////////////////////////////////////////////////////////
        $arr_is_active = array('0' => '<span class=no>' . _NO . '</span>', '1' => '<span class=yes>' . _YES . '</span>');
        $help_tooltip = '<br><img src=\'' . APPHP_BASE . 'images/question_mark.png\' alt=\'\' /> Ex.: http://www.youtube.com/watch?v=5VIV8nt2KkU - or - http://localhost/{your site}/my_video.wmv';
        //----------------------------------------------------------------------
        // VIEW MODE
        //----------------------------------------------------------------------
        $this->VIEW_MODE_SQL = 'SELECT
									gi.' . $this->primaryKey . ',
									gi.album_code,
									gi.item_file,
									gi.item_file_thumb,
									gi.priority_order,
									gi.is_active,
									gid.name,
									gid.description
								FROM (' . $this->tableName . ' gi	
									LEFT OUTER JOIN ' . TABLE_GALLERY_ALBUM_ITEMS_DESCRIPTION . ' gid ON gi.id = gid.gallery_album_item_id AND gid.language_id = \'' . $this->languageId . '\')';
        // define view mode fields
        if ($album_info[0]['album_type'] == 'video') {
            $this->arrViewModeFields['name'] = array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '20%', 'maxlength' => '30');
            $this->arrViewModeFields['item_file'] = array('title' => _VIDEO, 'type' => 'label', 'align' => 'left', 'width' => '40%');
        } else {
            $this->arrViewModeFields['item_file_thumb'] = array('title' => _IMAGE, 'type' => 'image', 'align' => 'left', 'width' => '60px', 'sortable' => false, 'nowrap' => '', 'visible' => '', 'image_width' => '50px', 'image_height' => '30px', 'target' => 'images/gallery/', 'no_image' => 'no_image.png');
            $this->arrViewModeFields['name'] = array('title' => _NAME, 'type' => 'label', 'align' => 'left', 'width' => '20%', 'maxlength' => '30');
        }
        $this->arrViewModeFields['description'] = array('title' => _DESCRIPTION, 'type' => 'label', 'align' => 'left', 'width' => '', 'maxlength' => '60');
        $this->arrViewModeFields['priority_order'] = array('title' => _ORDER, 'type' => 'label', 'align' => 'center', 'width' => '10%', 'movable' => true);
        $this->arrViewModeFields['is_active'] = array('title' => _ACTIVE, 'type' => 'enum', 'align' => 'center', 'width' => '10%', 'sortable' => true, 'nowrap' => '', 'visible' => true, 'source' => $arr_is_active);
        //----------------------------------------------------------------------
        // ADD MODE
        //----------------------------------------------------------------------
        // define add mode fields
        $this->arrAddModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'priority_order' => array('title' => _ORDER, 'type' => 'textbox', 'width' => '60px', 'maxlength' => '3', 'required' => true, 'readonly' => false, 'validation_type' => 'numeric'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'default' => '1', 'true_value' => '1', 'false_value' => '0'), 'album_code' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $album)));
        if ($album_info[0]['album_type'] == 'video') {
            $this->arrAddModeFields['separator_general']['item_file'] = array('title' => _VIDEO . ' (http://)', 'type' => 'textbox', 'width' => '370px', 'maxlength' => '255', 'required' => false, 'readonly' => false, 'validation_type' => '', 'post_html' => $help_tooltip);
            $this->arrAddModeFields['separator_general']['item_file_thumb'] = array('title' => _THUMBNAIL . ' (http://)', 'type' => 'textbox', 'width' => '370px', 'maxlength' => '255', 'required' => false, 'readonly' => false, 'validation_type' => '');
        } else {
            $this->arrAddModeFields['separator_general']['item_file'] = array('title' => _IMAGE, 'type' => 'image', 'width' => '210px', 'required' => true, 'readonly' => false, 'target' => 'images/gallery/', 'thumbnail_create' => true, 'thumbnail_field' => 'item_file_thumb', 'thumbnail_width' => $icon_width, 'thumbnail_height' => $icon_height, 'file_maxsize' => '900k');
        }
        //----------------------------------------------------------------------
        // EDIT MODE
        //----------------------------------------------------------------------
        $this->EDIT_MODE_SQL = 'SELECT
								' . $this->primaryKey . ',
								album_code,
								item_file,
								item_file_thumb,
								priority_order,
								' . $sql_translation_description . '
								is_active
							FROM ' . $this->tableName . '
							WHERE ' . $this->primaryKey . ' = _RID_';
        // define edit mode fields
        $this->arrEditModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'priority_order' => array('title' => _ORDER, 'type' => 'textbox', 'width' => '60px', 'maxlength' => '3', 'required' => true, 'readonly' => false, 'validation_type' => 'numeric'), 'is_active' => array('title' => _ACTIVE, 'type' => 'checkbox', 'readonly' => false, 'true_value' => '1', 'false_value' => '0'), 'album_code' => array('title' => '', 'type' => 'hidden', 'required' => true, 'readonly' => false, 'default' => $album)));
        if ($album_info[0]['album_type'] == 'video') {
            $this->arrEditModeFields['separator_general']['item_file'] = array('title' => _VIDEO . ' (http://) ', 'type' => 'textbox', 'width' => '370px', 'maxlength' => '255', 'required' => false, 'readonly' => false, 'validation_type' => '', 'post_html' => $help_tooltip);
            $this->arrEditModeFields['separator_general']['item_file_thumb'] = array('title' => _THUMBNAIL . ' (http://)', 'type' => 'textbox', 'width' => '370px', 'maxlength' => '255', 'required' => false, 'readonly' => false, 'validation_type' => '');
        } else {
            $this->arrEditModeFields['separator_general']['item_file'] = array('title' => _IMAGE, 'type' => 'image', 'width' => '210px', 'required' => true, 'readonly' => false, 'target' => 'images/gallery/', 'thumbnail_create' => true, 'thumbnail_field' => 'item_file_thumb', 'thumbnail_width' => $icon_width, 'thumbnail_height' => $icon_height, 'file_maxsize' => '900k');
        }
        //----------------------------------------------------------------------
        // DETAILS MODE
        //----------------------------------------------------------------------
        $this->DETAILS_MODE_SQL = $this->EDIT_MODE_SQL;
        $this->arrDetailsModeFields = array('separator_general' => array('separator_info' => array('legend' => _GENERAL), 'priority_order' => array('title' => _ORDER, 'type' => 'label'), 'is_active' => array('title' => _ACTIVE, 'type' => 'enum', 'source' => $arr_is_active)));
        if ($album_info[0]['album_type'] == 'video') {
            $this->arrDetailsModeFields['separator_general']['item_file'] = array('title' => _VIDEO, 'type' => 'object', 'width' => '240px', 'height' => '200px');
            $this->arrDetailsModeFields['separator_general']['item_file_thumb'] = array('title' => _THUMBNAIL, 'type' => 'label');
        } else {
            $this->arrDetailsModeFields['separator_general']['item_file'] = array('title' => _IMAGE, 'type' => 'image', 'target' => 'images/gallery/', 'no_image' => 'no_image.png');
        }
        ///////////////////////////////////////////////////////////////////////////////
        // 3. add translation fields to all modes
        $this->AddTranslateToModes($this->arrTranslations, array('name' => array('title' => _NAME, 'type' => 'textbox', 'width' => '410px', 'required' => false, 'maxlength' => '125', 'readonly' => false), 'description' => array('title' => _DESCRIPTION, 'type' => 'textarea', 'width' => '410px', 'height' => '70px', 'required' => false, 'maxlength' => '255', 'validation_maxlength' => '255', 'readonly' => false)));
        ///////////////////////////////////////////////////////////////////////////////
    }
/**
* @project ApPHP Business Directory
* @copyright (c) 2011 ApPHP
* @author ApPHP <*****@*****.**>
* @license http://www.gnu.org/licenses/
*/
// *** Make sure the file isn't accessed directly
defined('APPHP_EXEC') or die('Restricted Access');
//--------------------------------------------------------------------------
if ($objLogin->IsLoggedInAs('owner', 'mainadmin') && Modules::IsModuleInstalled('gallery')) {
    $action = MicroGrid::GetParameter('action');
    $rid = MicroGrid::GetParameter('rid');
    $mode = 'view';
    $msg = '';
    $objAlbums = new GalleryAlbums();
    if ($action == 'add') {
        $mode = 'add';
    } else {
        if ($action == 'create') {
            if ($objAlbums->AddRecord()) {
                $msg = draw_success_message(_ADDING_OPERATION_COMPLETED, false);
                $mode = 'view';
            } else {
                $msg = draw_important_message($objAlbums->error, false);
                $mode = 'add';
            }
        } else {
            if ($action == 'edit') {
                $mode = 'edit';
            } else {
 /**
  * Given an album, generates a link to its parent. Must be implemented by child classes to generate
  * a valid URL.
  *
  * @param album The album
  */
 function parentAlbumLink($album)
 {
     if ($album->getParentId() == 0) {
         // if the parent album is the root album, let's make it easy...
         $albumLink = $this->albumLink(null);
     } else {
         // i don't really like this bit because suddenly, a request generator class
         // starts loading objects from the db...
         $albums = new GalleryAlbums();
         $parentAlbum = $albums->getAlbum($album->getParentId());
         $albumLink = $this->albumLink($parentAlbum);
     }
     return $albumLink;
 }
Example #18
0
 /**
  * Include style and javascript files
  */
 public static function SetLibraries()
 {
     $nl = "\n";
     $output = '<script type="text/javascript" src="' . APPHP_BASE . 'js/jquery-1.6.3.min.js"></script>' . $nl;
     $output .= GalleryAlbums::SetLibraries();
     if (!self::Get('js_included', 'lytebox')) {
         $output .= '<link rel="stylesheet" href="' . APPHP_BASE . 'modules/lytebox/css/lytebox.css" type="text/css" media="screen" />' . $nl;
         $output .= '<script type="text/javascript" src="' . APPHP_BASE . 'modules/lytebox/js/lytebox.js"></script>' . $nl;
         Application::Set('js_included', 'lytebox');
     }
     return $output;
 }
Example #19
0
// load the category as defined in the plugin settings page
$categoryId = $blogSettings->getValue("plugin_moblog_article_category_id");
$category = $articleCategories->getCategory($categoryId, $blogInfo->getId());
// if there was no such category, we should send an error and to make it more useful, send
// as part of the error message the list of available categories
if (!$category) {
    $response = new MoblogResponse($request->getReplyTo(), "pLog Moblog: Error", "The category does not exist.");
    MoblogLogger::log("User '" . $request->getUser() . "' tried to use category '" . $categoryId . "' which does not exist.");
    $response->send();
    return false;
}
//
// finally, add the resources to the database
//
// first, create a new album to hold these attachments
$albums = new GalleryAlbums();
$userAlbums = $albums->getUserAlbums($blogInfo->getId());
$t = new Timestamp();
$albumId = $blogSettings->getValue("plugin_moblog_gallery_resource_album_id");
$album = $albums->getAlbum($albumId, $blogInfo->getId());
// check if the album was loaded
if (!$album) {
    $response = new MoblogResponse($request->getReplyTo(), "pLog Moblog: Error", "The album does not exist.");
    MoblogLogger::log("User '" . $request->getUser() . "' tried to use album '" . $albumId . "' which does not exist.");
    $response->send();
    return false;
}
MoblogLogger::log("Adding resources to album " . $album->getName());
$attachments = $request->getAttachments();
$res = new GalleryResources();
$resourceIds = array();
 /**
  * Given an album, generates a link to its parent. Must be implemented by child classes to generate
  * a valid URL.
  *
  * @param album The album
  */
 function parentAlbumLink($album)
 {
     if ($album->getParentId() > 0) {
         $galleryAlbums = new GalleryAlbums();
         $parentAlbum = $galleryAlbums->getAlbum($album->getParentId());
         $albumLink = $this->getBaseUrl() . '/' . $this->_blogInfo->getId() . '_' . StringUtils::text2url($this->_blogInfo->getBlog()) . '/albums/' . $album->getParentId() . '_' . StringUtils::text2url($parentAlbum->getName()) . '.html';
     } else {
         // this will return the default link to the albums
         $albumLink = $this->getBaseUrl() . '/' . $this->_blogInfo->getId() . '_' . StringUtils::text2url($this->_blogInfo->getBlog()) . '/albums/';
     }
     return $albumLink;
 }
Example #21
0
function metaWeblogNewMediaObject($args)
{
    global $users, $articles, $blogsG;
    /*
        "userid" =>
        "dateCreated" =>
        "content" =>
        "postid" =>
    */
    $blogid = $args[0];
    $username = $args[1];
    $password = $args[2];
    $file = $args[3];
    $erg = $users->getUserInfo($username, $password);
    if ($erg != false) {
        // Save this file to the tmp directory
        // Create a temp file
        // Get the temp directory
        /**if (!$tmp_dir = get_cfg_var('upload_tmp_dir')) {
               $tmp_dir = dirname(tempnam('/tmp', ''));
           }*/
        $config =& Config::getConfig();
        $tmp_dir = $config->getTempFolder();
        // Remove all characters that would need to be urlencoded
        // This may not be necessary, but this was causing problems when given file
        // names with spaces in it.
        $tempFile = ereg_replace("[^a-zA-Z0-9._-]", "_", basename($file['name']));
        // Make the tmp name
        $tempFile = $tmp_dir . '/' . $tempFile;
        // Open the file
        if (!($handle = fopen($tempFile, "wb"))) {
            return new IXR_Error(-1, 'Could not open file');
        }
        // It appears that the data has already been decoded, no need to call base64_decode
        $decodedBits = $file['bits'];
        // Write the data to the file
        if (fwrite($handle, $decodedBits) === false) {
            return new IXR_Error(-1, 'Could not write to file');
        }
        // Close the file
        fclose($handle);
        // let the gallery library do its work...
        $resources = new GalleryResources();
        // Get the first album for this blog
        $albums = new GalleryAlbums();
        // get the list of albums for this blog
        $albumArray = $albums->getUserAlbums($blogid);
        if ($albumArray == NULL || count($albumArray) == 0) {
            return new IXR_Error(-1, 'Could not find album');
        }
        // Add the resource to the first album
        $resId = $resources->addResourceFromDisk($blogid, $albumArray[0]->getId(), basename($file['name']), $tempFile);
        // Get the resource from the id
        $resource = $resources->getResource($resId, $blogid, $albumArray[0]->getId());
        // Now we need to get the url for the resource
        $blogInfo = $blogsG->getBlogInfo($blogid);
        $url = $blogInfo->getBlogRequestGenerator();
        $ret = $url->resourceDownloadLink($resource);
        return $ret;
    } else {
        return new IXR_Error(-1, 'You did not provide the correct password');
    }
}
 /**
  * Returns how many child albums this album has.
  *
  * @return An integer, or '0' if the album has no children.
  */
 function getNumChildren()
 {
     // breaking the rules here again...
     if ($this->_numChildren == -1) {
         $albums = new GalleryAlbums();
         $this->_numChildren = $albums->getNumChildren($this->getId());
     }
     return $this->_numChildren;
 }
Example #23
0
 /**
  * Draw page text
  */
 public function DrawText()
 {
     global $objLogin;
     $objGallery = new GalleryAlbums();
     $objContactUs = ContactUs::Instance();
     $replace_needles = 1;
     $module_page = false;
     if (!count($this->page)) {
         return false;
     }
     // dont show this page if it was expired
     if (!$objLogin->IsLoggedInAsAdmin() && $this->page['finish_publishing'] != '0000-00-00' && date('Y-m-d') > $this->page['finish_publishing']) {
         draw_important_message(_PAGE_EXPIRED);
         return false;
     }
     if ($this->page['content_type'] == 'article' && isset($this->page['page_text'])) {
         $page_text = decode_text($this->page['page_text'], false);
         echo '<div class="pages_contents">';
         if (preg_match('/{module:gallery}/i', $page_text)) {
             $module_page = true;
             $page_text = @preg_replace('/{module:gallery}/i', $objGallery->DrawGallery(false), $page_text, 1);
         }
         if (preg_match_all('/{module:album=(.*?)}/i', $page_text, $matches)) {
             $module_page = true;
             if (is_array($matches[1])) {
                 foreach ($matches[1] as $key => $val) {
                     if (strtolower($val) != 'code') {
                         $val = @preg_replace('/[^A-Za-z0-9:]/i', '', $val);
                         $page_text = @preg_replace('/{module:album=' . $val . '}/i', $objGallery->DrawAlbum($val, false), $page_text, 1);
                     }
                 }
             }
         }
         if (self::$PROJECT == 'MedicalAppointment') {
             if (preg_match('/{module:about_us}/i', $page_text)) {
                 $module_page = true;
                 $page_text = @preg_replace('/{module:about_us}/i', Clinic::DrawAboutUs(false), $page_text, 1);
             }
         }
         if (self::$PROJECT == 'HotelSite') {
             if (preg_match('/{module:about_us}/i', $page_text)) {
                 $module_page = true;
                 $page_text = @preg_replace('/{module:about_us}/i', Hotels::DrawAboutUs(false), $page_text, 1);
             }
             if (preg_match('/{module:rooms}/i', $page_text)) {
                 $module_page = true;
                 $page_text = @preg_replace('/{module:rooms}/i', Rooms::DrawRoomsInfo(false), $page_text, 1);
             }
             if (preg_match('/{module:testimonials}/i', $page_text)) {
                 $module_page = true;
                 $page_text = @preg_replace('/{module:testimonials}/i', Testimonials::DrawTestimonails(false), $page_text, 1);
             }
         }
         if (preg_match('/{module:contact_us}/i', $page_text)) {
             $module_page = true;
             $page_text = @preg_replace('/{module:contact_us}/i', $objContactUs->DrawContactUsForm(false), $page_text, 1);
         }
         if (preg_match('/{module:faq}/i', $page_text)) {
             $module_page = true;
             $page_text = @preg_replace('/{module:faq}/i', FaqCategories::DrawFaqList(false), $page_text, 1);
         }
         if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
             $page_text = stripslashes($page_text);
         }
         if ($this->page['is_home']) {
             if (self::$PROJECT == 'HotelSite') {
                 Campaigns::DrawCampaignBanner('standard');
                 Campaigns::DrawCampaignBanner('global');
             }
         }
         //echo $page_text;
         //echo "<hr>";
         // draw all needed blocks for Home page
         if ($this->page['is_home']) {
             if (self::$PROJECT == 'BusinessDirectory') {
                 if (ModulesSettings::Get('listings', 'show_categories_home_block') == 'yes') {
                     Categories::DrawHomePageBlock();
                 }
             } else {
                 if (self::$PROJECT == 'ShoppingCart') {
                     if (ModulesSettings::Get('products_catalog', 'is_active') == 'yes') {
                         Campaigns::DrawCampaignBanner();
                         if (ModulesSettings::Get('products_catalog', 'show_featured_block') == 'home page') {
                             Products::DrawFeaturedBlock('home');
                         }
                         if (ModulesSettings::Get('products_catalog', 'show_new_products_block') == 'home page') {
                             Products::DrawNewProductsBlock();
                         }
                         Categories::DrawHomePageBlock();
                     }
                 }
             }
         }
         // draw comments form
         if (!$this->page['is_home'] && !$module_page) {
             if (Modules::IsModuleInstalled('comments')) {
                 if (ModulesSettings::Get('comments', 'comments_allow') == 'yes' && $this->page['comments_allowed']) {
                     $objComments = new Comments();
                     $objComments->DrawArticleComments($this->page['id']);
                 }
             }
         }
         echo '</div>';
     } else {
         if ($this->page['content_type'] == 'link' && isset($this->page['link_url'])) {
             $link_url = decode_text($this->page['link_url']);
             echo '<div class="pages_contents">';
             echo '<a href="' . $link_url . '">' . $link_url . '</a>';
             echo '</div>';
         }
     }
 }
Example #24
0
<?php

/**
* @project ApPHP Business Directory
* @copyright (c) 2011 ApPHP
* @author ApPHP <*****@*****.**>
* @license http://www.gnu.org/licenses/
*/
// *** Make sure the file isn't accessed directly
defined('APPHP_EXEC') or die('Restricted Access');
//--------------------------------------------------------------------------
if (Modules::IsModuleInstalled('gallery')) {
    $objGalleryAlbum = new GalleryAlbums();
    $objGalleryAlbum->DrawAlbum(Application::Get('album_code'));
} else {
    draw_important_message(_PAGE_UNKNOWN);
}
?>
	
	
Example #25
0
<?php

//$SQL='select COUNT(*) as rowCount from news02news where news02uin>0 ';
///$data=Query($SQL);
//$page='News';
//$objCat= new NewsType();
$objAlbums = new GalleryAlbums();
$data['_data'] = $objAlbums->get('', '', 6);
$data['prefix'] = $objAlbums->getPrefix();
$data['upload_url'] = UPLOADS . $objAlbums->getUploadURL();
echo defaultModule($strModuleName, $data);
 function validate()
 {
     // before we do anything, let's find out the blogId and if there isn't any, quit
     $this->_getBlogInfo();
     if ($this->_blogInfo == false) {
         // return 404 not found because the blog id is not correct!
         $this->_view = new ResourceServerView();
         $this->_view->addHeaderResponse("HTTP/1.1 404 Not Found");
         $this->_view->addHeaderResponse("Status: 404 Not Found");
         $this->_view->addHeaderResponse("X-pLog-Error: Blog {$resId} is not correct");
         return false;
     }
     //
     // security stuff
     //
     // :KLUDGE: the problem with the security Pipeline and the PluginManager in this
     // action is that we need to reimplement the whole stuff because... this action does not
     // inherit from BlogAction and therefore nobody is doing these things for us! I don't really
     // like to do it like this but while I think of a better way, let's leave like it
     //
     $pipeline = new Pipeline($this->_request, $this->_blogInfo);
     $result = $pipeline->process();
     // if the pipeline blocked the request, then we have to let the user know and quit
     // processing
     if (!$result->isValid()) {
         $this->_view = new ResourceServerView();
         $this->_view->addHeaderResponse("HTTP/1.1 403 Forbidden");
         $this->_view->addHeaderResponse("Status: 403 Forbidden");
         $this->_view->addHeaderResponse("X-pLog-Error: Access is blocked");
         return false;
     }
     // now if the blog id was correct, then we can proceed to get the rest of the parameters
     $this->_resName = $this->_request->getValue("resource");
     $this->_resId = $this->_request->getValue("resId");
     $this->_albumId = $this->_request->getValue("albumId");
     $this->_albumName = $this->_request->getValue("albumName");
     $this->_mode = $this->_request->getValue("mode");
     // check if we need to load the album to figure out the correct album id
     // because we got an album name instead of an album id
     if (!empty($this->_albumId) || !empty($this->_albumName)) {
         if ($this->_albumName) {
             $albums = new GalleryAlbums();
             $album = $albums->getAlbumByName($this->_albumName);
             if (!$album) {
                 $this->_view = new ResourceServerView();
                 $this->_view->addHeaderResponse("HTTP/1.1 404 Not Found");
                 $this->_view->addHeaderResponse("Status: 404 Not Found");
                 $this->_view->addHeaderResponse("X-pLog-Error: Album {$albumId} not found");
                 return false;
             }
             $this->_albumId = $album->getId();
         }
     }
     return true;
 }
Example #27
0
<?php 
$obj = new GalleryAlbums();
$ct = 0;
$prefix1 = $obj->getPrefix();
$uploadUrl = $obj->getUploadURL();
$_data = $obj->get();
$data['data'] = $_data;
$data['prefix'] = $prefix1;
$data['uploadUrl'] = $obj->getUploadURL();
echo defaultModule($strModuleName, $data);
/**
* @project ApPHP Business Directory
* @copyright (c) 2011 ApPHP
* @author ApPHP <*****@*****.**>
* @license http://www.gnu.org/licenses/
*/
// *** Make sure the file isn't accessed directly
defined('APPHP_EXEC') or die('Restricted Access');
//--------------------------------------------------------------------------
if ($objLogin->IsLoggedInAsAdmin() && Modules::IsModuleInstalled('gallery')) {
    $action = MicroGrid::GetParameter('action');
    $rid = MicroGrid::GetParameter('rid');
    $album = MicroGrid::GetParameter('album', false);
    $mode = 'view';
    $msg = '';
    $objAlbums = new GalleryAlbums();
    $album_info = $objAlbums->GetAlbumInfo($album);
    if (count($album_info) > 0) {
        $objAlbumItems = new GalleryAlbumItems();
        if ($action == 'add') {
            $mode = 'add';
        } else {
            if ($action == 'create') {
                if ($objAlbumItems->AddRecord()) {
                    $msg = draw_success_message(_ADDING_OPERATION_COMPLETED, false);
                    $mode = 'view';
                } else {
                    $msg = draw_important_message($objAlbumItems->error, false);
                    $mode = 'add';
                }
            } else {
 /**
  * deletes resources from the list
  */
 function _deleteAlbums()
 {
     $albums = new GalleryAlbums();
     // loop through the array of resource ids and
     // remove them all
     foreach ($this->_albumIds as $albumId => $value) {
         // fetch the resource first, to get some info about it
         $album = $albums->getAlbum($albumId, $this->_blogInfo->getId());
         if (!$album) {
             $this->_errorMessage .= $this->_locale->pr("error_deleting_album2", $albumId) . "<br/>";
         } else {
             if ($album->getNumChildren() > 0 || $album->getNumResources() > 0) {
                 $this->_errorMessage .= $this->_locale->pr("error_album_has_children", $album->getName());
             } else {
                 $this->notifyEvent(EVENT_PRE_ALBUM_DELETE, array("album" => &$album));
                 // and now remove it
                 $res = $albums->deleteAlbum($albumId, $this->_blogInfo->getId());
                 if ($res) {
                     $this->_totalOk++;
                     if ($this->_totalOk > 1) {
                         $this->_successMessage = $this->_locale->pr("items_deleted_ok", $this->_totalOk);
                     } else {
                         $this->_successMessage = $this->_locale->pr("item_deleted_ok", $album->getName());
                     }
                     $this->notifyEvent(EVENT_POST_ALBUM_DELETE, array("album" => &$album));
                 } else {
                     $this->_errorMessage .= $this->_locale->pr("error_deleting_album", $album->getName()) . "<br/>";
                 }
             }
         }
     }
     return true;
 }