/** * Load your component. * * @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page */ public function load(\Cx\Core\ContentManager\Model\Entity\Page $page) { global $_CORELANG, $subMenuTitle, $objTemplate; switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND: $objGallery = new Gallery(\Env::get('cx')->getPage()->getContent()); \Env::get('cx')->getPage()->setContent($objGallery->getPage()); $topGalleryName = $objGallery->getTopGalleryName(); if ($topGalleryName) { \Env::get('cx')->getPage()->setTitle($topGalleryName); \Env::get('cx')->getPage()->setContentTitle($topGalleryName); \Env::get('cx')->getPage()->setMetaTitle($topGalleryName); } break; case \Cx\Core\Core\Controller\Cx::MODE_BACKEND: $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'LegacyContentMaster.html'); $objTemplate = $this->cx->getTemplate(); \Permission::checkAccess(12, 'static'); $subMenuTitle = $_CORELANG['TXT_GALLERY_TITLE']; $objGalleryManager = new GalleryManager(); $objGalleryManager->getPage(); break; default: break; } }
/** * The gallery index handler. * * @access public * @return string The HTML code. */ public function index() { $Gallery = new Gallery(); $params = array(); $params[] = 'Type = ' . Gallery::GALLERY; $this->getView()->set('Galleries', $Gallery->findList($params, 'Position asc')); return $this->getView()->render(); }
function forceAlbum($success) { // we presume that the site only serves the one album. $gallery = new Gallery(); $albums = $gallery->getAlbums(); $_GET['album'] = array_shift($albums); return $success; }
/** * The development index handler. * * @access public * @return string The HTML code. */ public function index() { $Gallery = new Gallery(); $Award = new Award(); $this->getView()->set('Gallery', $Gallery->findItem(array('Type = ' . Gallery::DEVELOPMENT))); $this->getView()->set('Patents', $Award->findList(array('Type = ' . Award::PATENT), 'Position asc')); return $this->getView()->render(); }
function _initFormForGallery(&$form, $gallery_id) { require_once 'Modules/Gallery/Gallery.php'; $dbcon =& AMP_Registry::getDbcon(); $publish_item = new Gallery($dbcon, $gallery_id); $title = 'Photo Gallery: ' . $publish_item->getName(); return $this->_initFormPublishItem($form, $publish_item, AMP_CONTENT_CLASS_DEFAULT, $title); }
function delete($cat_id, $id = FALSE) { if ($id) { $gallery = new Gallery($id); $gallery->delete_file($gallery->id, 'uploads/galleries/', 'image'); $gallery->delete(); set_notify('success', lang('delete_data_complete')); } redirect('galleries/admin/galleries/index/' . $cat_id); }
function lamtech_preprocess_node(&$vars) { // kpr($vars); if (isset($vars['content']['field_category']) && count($vars['content']['field_category'])) { $vars['category'] = $vars['content']['field_category'][0]; unset($vars['content']['field_category']); } $helper = NULL; switch ($vars['type']) { case 'cta': require_once DRUPAL_ROOT . '/' . drupal_get_path('theme', 'lamtech') . '/tpl/anb/cta/CTA.php'; $helper = new CTA(); $helper->preprocess($vars); break; case 'features_intro': require_once DRUPAL_ROOT . '/' . drupal_get_path('theme', 'lamtech') . '/tpl/anb/fi/FeaturesIntro.php'; $helper = new FeaturesIntro(); $helper->preprocess($vars); break; case 'gallery': require_once DRUPAL_ROOT . '/' . drupal_get_path('theme', 'lamtech') . '/tpl/anb/gallery/Gallery.php'; $helper = new Gallery(); $helper->preprocess($vars); break; case 'testimonials': require_once DRUPAL_ROOT . '/' . drupal_get_path('theme', 'lamtech') . '/tpl/anb/testimonials/Testimonials.php'; $helper = new Testimonials(); $helper->preprocess($vars); break; case 'hero': require_once DRUPAL_ROOT . '/' . drupal_get_path('theme', 'lamtech') . '/tpl/anb/hero/Hero.php'; $helper = new Hero(); $helper->preprocess($vars); break; case 'team': require_once DRUPAL_ROOT . '/' . drupal_get_path('theme', 'lamtech') . '/tpl/anb/team/Team.php'; $helper = new Team(); $helper->preprocess($vars); break; case 'statistic': require_once DRUPAL_ROOT . '/' . drupal_get_path('theme', 'lamtech') . '/tpl/anb/statistic/Statistic.php'; $helper = new Statistic(); $helper->preprocess($vars); break; case 'contact_info': require_once DRUPAL_ROOT . '/' . drupal_get_path('theme', 'lamtech') . '/tpl/anb/contact-info/ContactInfo.php'; $helper = new ContactInfo(); $helper->preprocess($vars); break; case 'advanced_page': unset($vars['content']['field_hide_title']); break; } // kpr($vars); }
public function createAndUploadPhoto(Gallery $gallery, array $values, \Nette\Web\HttpUploadedFile $file) { if (!$file->isImage()) { throw new ValidationException("Soubor není obrázek."); } $photo = $this->createBlank(); $this->update($photo, $values); $gallery->addPhoto($photo); @mkdir(pathinfo($photo->getFilePath(), PATHINFO_DIRNAME), 0777, true); $file->toImage()->resize($this->maxWidth, $this->maxHeight)->save($photo->getFilePath()); $this->save($gallery); }
/** * Функция вывода галереи * * @param string $gallery_id идентификатор галереи * и опционально количество изображений на странице */ function mod_gallery($gallery_id) { global $AVE_Template; require_once BASE_DIR . '/modules/gallery/class.gallery.php'; $gallery = new Gallery(); $own_lim = @explode('-', stripslashes($gallery_id)); $lim = empty($own_lim[1]) ? '' : $own_lim[1]; $gallery_id = $own_lim[0]; $tpl_dir = BASE_DIR . '/modules/gallery/templates/'; $lang_file = BASE_DIR . '/modules/gallery/lang/' . $_SESSION['user_language'] . '.txt'; $AVE_Template->config_load($lang_file); $gallery->galleryShow($tpl_dir, $gallery_id, $lim); }
function getList($params = NULL, $proyection = '*', $order = '1', $limit = '') { if ($this->db != NULL) { $this->db->read($this->table, $proyection, $params); $r = array(); while ($param = $this->db->getRow()) { $gallery = new Gallery(); $gallery->set($param); $r[] = $gallery; } return $r; } return NULL; }
/** * {@inheritdoc} */ public function synchronize() { $this->pictures = array(); $config = GalleryConfig::load(); $Gallery = new Gallery(); $result = PersistenceContext::get_querier()->select("SELECT g.id, g.name, g.path, g.width, g.height, g.idcat, gc.auth\n\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\tLEFT JOIN " . GallerySetup::$gallery_cats_table . " gc on gc.id = g.idcat\n\t\tWHERE g.aprob = 1\n\t\tORDER BY RAND()\n\t\tLIMIT 30"); while ($row = $result->fetch()) { $row['auth'] = $row['idcat'] == 0 ? $config->get_authorizations() : unserialize(stripslashes($row['auth'])); //Calcul des dimensions avec respect des proportions. list($row['width'], $row['height']) = $Gallery->get_resize_properties($row['width'], $row['height']); $this->pictures[$row['id']] = $row; } $result->dispose(); }
function email_new_user_save($savemsg, $userobj, $what) { global $_zp_authority; if ($what == 'new' && ($mail = $userobj->getEmail())) { $gallery = new Gallery(); $ref = $_zp_authority->getResetTicket($adm = $userobj->getUser(), $userobj->getPass()); $msg = "\n" . sprintf(gettext('You are receiving this e-mail because a user code (%1$s) has been created for you on the Zenphoto gallery %2$s.'), $adm, $gallery->getTitle()) . "\n" . sprintf(gettext('To set your Zenphoto User password visit: %s'), FULLWEBPATH . "/" . ZENFOLDER . "/admin-users.php?ticket={$ref}&user={$adm}") . "\n" . gettext("This ticket will automatically expire in 3 days."); $err_msg = zp_mail(gettext("The Zenphoto user created"), $msg, array($mail)); if (!empty($err_msg)) { $savemsg .= $err_msg; } } return $savemsg; }
public function uploadPhoto(Gallery $gallery, array $values, \Nette\Web\HttpUploadedFile $file) { if (!$file->isImage()) { throw new \Neuron\Model\ValidationException("File is not image."); } // save image $image = $file->toImage()->resize($this->maxWidth, $this->maxHeight); $values['hash'] = $this->repository->save((string) $image); // save entity $em = $this->getEntityManager(); $photo = new Photo($values); $em->persist($photo); $gallery->addPhoto($photo); $em->flush(); }
public function actionShow($id) { $model = Gallery::model()->findByPk((int) $id); if (is_null($model)) { throw new CHttpException(404, Yii::t('gallery', 'Страница не найдена!')); } $image = new Image(); if (Yii::app()->request->isPostRequest && isset($_POST['Image'])) { $transaction = Yii::app()->db->beginTransaction(); try { $image = $image->create($_POST['Image']); if (!$image->hasErrors()) { if ($model->addImage($image)) { Yii::app()->user->setFlash(YFlashMessages::NOTICE_MESSAGE, Yii::t('gallery', 'Фотография добавлена!')); } $transaction->commit(); $this->redirect(array('/gallery/gallery/show/', 'id' => $model->id)); } throw new CDbException(Yii::t('gallery', 'При добавлении изображения произошла ошибка!')); } catch (Exception $e) { $transaction->rollback(); Yii::app()->user->setFlash(YFlashMessages::ERROR_MESSAGE, Yii::t('gallery', $e->getMessage())); } } $dataProvider = new CActiveDataProvider('ImageToGallery', array('criteria' => array('condition' => 'galleryId = :galleryId', 'params' => array(':galleryId' => $model->id), 'limit' => self::GALLERY_PER_PAGE, 'order' => 't.creation_date DESC', 'with' => 'image'), 'pagination' => array('pageSize' => self::GALLERY_PER_PAGE))); $this->render('show', array('image' => $image, 'model' => $model, 'dataProvider' => $dataProvider)); }
private static function generate_data_for_day(SS_Datetime $date) { $data = array('timestamp' => time(), 'searchDate' => $date->Format("Y-m-d"), 'collections' => array('events' => array(), 'galleries' => array(), 'locations' => array())); $galleryIDs = array(); $locationIDs = array(); // Get events $where = sprintf("DATE(`StartDate`) = '%s'", $date->Format('Y-m-d')); $events = Event::get()->where($where)->exclude(array("GalleryID" => 0, "Gallery.LocationID" => 0)); foreach ($events as $event) { $galleryIDs[] = $event->GalleryID; $data['collections']['events'][] = $event->forAPI(); } // Get galleries $galleries = Gallery::get()->byIDs(array_unique($galleryIDs)); foreach ($galleries as $gallery) { $locationIDs[] = $gallery->LocationID; $data['collections']['galleries'][] = $gallery->forAPI(); } // Get locations $locations = Location::get()->byIDs(array_unique($locationIDs)); foreach ($locations as $location) { $data['collections']['locations'][] = $location->forAPI(); } return $data; }
function getList($pagina = 1, $orden = "", $nrpp = Configuracion::NRPP, $condicion = "1=1", $parametros = array()) { $ordenPredeterminado = "{$orden}, id_imagen"; if (trim($orden) === "" || trim($orden) === NULL) { $ordenPredeterminado = "id_imagen"; } $registroInicial = ($pagina - 1) * $nrpp; $this->bd->select($this->tabla, "*", $condicion, $parametros, $ordenPredeterminado, "{$registroInicial}, {$nrpp}"); $r = array(); while ($fila = $this->bd->getRow()) { $imagen = new Gallery(); $imagen->set($fila); $r[] = $imagen; } return $r; }
public function createNewEvent($writeUpdate = true) { $models = $this->createModels(); $location = Location::create_from_string($this->location); // Check for existing gallery $existingGallery = Gallery::get()->filter(array('Location.PlaceID' => $location->PlaceID))->first(); // If existing gallery, don't create a new one if ($existingGallery) { $location = $existingGallery->Location(); $models['Gallery'] = $existingGallery; } else { // Write location to database $location->write(); // Write gallery to database $models['Gallery']->update(array('LocationID' => $location->ID))->write(); } // Write event to database $models['Event']->update(array('GalleryID' => $models['Gallery']->ID))->write(); // Link event $this->update(array('EventID' => $models['Event']->ID, 'State' => 'Merged')); if ($writeUpdate) { $this->write(); } return $this->Event(); }
public function run() { $faker = Faker::create(); for ($i = 0; $i < 50; $i++) { Gallery::create(array('title' => $faker->sentence($nbwords = 5), 'slug' => $faker->slug, 'content' => $faker->text, 'excerpt' => $faker->sentence, 'gallery_category_id' => $faker->numberBetween(1, 5))); } }
public function getGallery() { $params = $this->getURLParams(); $galleryID = (int) $params['ID']; $gallery = Gallery::get()->filter(array('ID' => $galleryID))->first(); return $this->renderWith('Gallery', $gallery); }
/** * @param $id * @throws CDbException * @throws CHttpException */ public function actionView($id) { if (($gallery = Gallery::model()->published()->findByPk($id)) === null) { throw new CHttpException(404, Yii::t('GalleryModule.gallery', 'Page was not found!')); } $image = new Image(); if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST['Image'])) { try { $transaction = Yii::app()->db->beginTransaction(); $image->attributes = $_POST['Image']; if ($image->save() && $gallery->addImage($image)) { $transaction->commit(); Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('GalleryModule.gallery', 'Photo was created!')); $this->redirect(['/gallery/gallery/view', 'id' => $gallery->id]); } } catch (Exception $e) { $transaction->rollback(); Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, $e->getMessage()); } } if ($gallery->status == Gallery::STATUS_PRIVATE && $gallery->owner != Yii::app()->user->id) { throw new CHttpException(404); } $this->render('view', ['image' => $image, 'model' => $gallery]); }
public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Gallery::create([]); } }
/** * Initialize * * @param cfg */ function init($cfg) { //! get image sizes if (!empty($cfg['sizes'])) { foreach (!is_array($cfg['sizes']) ? str_getcsv($cfg['sizes']) : $cfg['sizes'] as $s) { self::$sizes[] = explode("x", $s); } } else { self::$sizes = [[57, 57], [480, 320], [1136, 640], [1280, 1024]]; } if (!empty($cfg['maxsize'])) { self::$maxSize = intval($cfg['maxsize']); if (self::$maxSize < 128) { self::$maxSize = 128; } } if (!empty($cfg['watermark']) && file_exists($cfg["Watermark"])) { self::$watermark = intval($cfg['watermark']); } if (!empty($cfg['minquality']) && $cfg['minquality'] > 1 && $cfg['minquality'] <= 10) { self::$minQuality = intval($cfg['minQuality']); } //! hangle gallery upload if (!empty($_FILES['imglist_upload'])) { Gallery::uploadImage($_FILES['imglist_upload']); } }
/** * handle add */ public function addComment($values) { $request = Request::getInstance(); $view = ViewManager::getInstance(); $values['active'] = 1; try { $id = $this->insert($values); $gallery = $this->plugin->getObject(Gallery::TYPE_DEFAULT); $galleryDetail = $gallery->getDetail(array('id' => $values['gal_id'])); $url = new Url(); $url->setPath($this->director->tree->getPath($galleryDetail['tree_id'])); $url->setParameter('id', $galleryDetail['id']); $url->setParameter($view->getUrlId(), Gallery::VIEW_DETAIL); // notify insert $ip = $request->getValue('REMOTE_ADDR', Request::SERVER); $template = new TemplateEngine($this->getPath() . "templates/gallerycommentemail.tpl"); $template->setVariable($values); $template->setVariable('galleryName', $galleryDetail['name']); $template->setVariable('href_detail', $url->getUrl()); $template->setVariable('siteTitle', $this->director->tree->getTreeName()); $template->setVariable('domain', $request->getDomain()); $template->setVariable('protocol', $request->getProtocol()); $template->setVariable('ip', $ip); $template->setVariable('host', gethostbyaddr($ip)); $template->setVariable('client', $request->getValue('HTTP_USER_AGENT', Request::SERVER)); $this->director->systemUser->notify($galleryDetail['tree_id'], 'Comment added at ' . $request->getDomain(), $template->fetch()); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('commentError', $e->getMessage(), false); $template->setVariable('cmtValues', $values, false); } }
function __construct($folder, $filename) { $this->gallery = Gallery::getInstance(); $this->folder = $folder; $this->filename = $filename; $this->iptcInfo = new IPTC($this->gallery->getPhotosPath() . DS . $this->folder->getFolderPath() . DS . $this->filename); }
/** @return Gallery Returns gallery associated with model */ public function getGallery() { if (empty($this->_gallery)) { $this->_gallery = Gallery::model()->findByPk($this->getOwner()->{$this->idAttribute}); } return $this->_gallery; }
/** * Remove the specified album from the database. * * @param int $id Id of the album * @return \Illuminate\View\View */ public function destroy($id) { $album = new Entity\Album(); $album->map(['id' => $id]); \Gallery::album()->delete($album); return \Redirect::route("gallery")->with('alertsuccess', \Lang::get('gallery::gallery.removal')); }
public static function returnShortCodes() { $tpl = static::returnTpl(); shortcode::add("gallery", function ($params = null) use($tpl) { $default = array('tpl' => "gallery-default"); $params = array_merge($default, (array) $params); if (empty($params['tpl']) || !View::exists($tpl . $params['tpl'])) { throw new Exception('Template not found: ' . $tpl . $params['tpl']); } if (!isset($params['id'])) { #return false; #return "Error: id of gallery is not defined!"; throw new Exception('ID of gallery is not defined'); } $gallery_id = $params['id']; $gallery = Gallery::where('id', $gallery_id)->first(); if (!is_object($gallery) || !@$gallery->id) { return false; #return "Error: gallery #{$gallery_id} doesn't exist!"; } $photos = $gallery->photos; if (!$photos->count()) { return false; } #dd($tpl.$params['tpl']); #dd(compact($photos)); #return View::make($tpl.$params['tpl'], compact($photos)); ## don't work return View::make($tpl . $params['tpl'], array('photos' => $photos)); }); }
private function __construct() { $this->gallery = Gallery::getInstance(); $this->folders = array(); // TODO is that effective? or use another data structure? $this->photos = array(); }
/** @return Gallery */ public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new Gallery(); } return self::$instance; }
private function handleTreeEditPost() { $request = Request::getInstance(); $values = $request->getRequest(Request::POST); try { if (!$request->exists('tree_id')) { throw new Exception('Node ontbreekt.'); } if (!$request->exists('tag')) { throw new Exception('Tag ontbreekt.'); } $tree_id = intval($request->getValue('tree_id')); $tag = $request->getValue('tag'); $key = array('tree_id' => $tree_id, 'tag' => $tag); if ($this->exists($key)) { $this->update($key, $values); } else { $this->insert($values); } $treeRef = new GalleryTreeRef(); $treeRef->delete($key); foreach ($values['ref_tree_id'] as $ref_tree_id) { $key['ref_tree_id'] = $ref_tree_id; $treeRef->insert($key); } viewManager::getInstance()->setType(ViewManager::ADMIN_OVERVIEW); $this->plugin->getReferer()->handleHttpGetRequest(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleTreeEditGet(false); } }