oxwall enable media panel insert pic from photo plugin

Life is short , play more!
本文来自lihao's Blog,转载请注明。

oxwall 允许media panel里插入上传的photo。 如下实验在oxwall 1.5.3 build 6341进行了验证。

oxwall media panel (in ow_system_plugins) has three menu , 1) upload picture 2) insert from the gallery 3) insert pictures from url.

I have tested on oxwall 1.5.3 build 6341.

If we installed the photo plugin, we ‘d like to insert the photo from ‘phot oplugin’ into the forum and blog posts.

I hacked three files, make media panel to support inserting the pic from the photo plugin.

Note: you must installed photo plugins.


1) /ox_system_plugins/base/controlers/media_panel.php

add the photos action method.

public function photogal($params)
	{

	#require("/work/oxwall/ow_plugins/photo/bol/photo_service.php");
		if ( OW::getRequest()->isPost() )
        {
            $userId = OW::getUser()->getId();
            if ( empty($userId) )
            {
                throw new Exception('Guests can\'t view this page');
            }

            $imgId = intval($_POST['img-id']);

            if ( $imgId <= 0 )
            {
                throw new Redirect404Exception();
            }

            BOL_MediaPanelService::getInstance()->deleteById($imgId);

            OW::getFeedback()->info(OW::getLanguage()->text('base', 'media_panel_file_deleted'));
            $this->redirect();
        }

        $pluginKey = $params['pluginKey'];
        $this->initMenu($params);
        $this->addComponent('menu', $this->menu);
        $this->menu->getElement('photogal');

		$albumService = PHOTO_BOL_PhotoAlbumService::getInstance();
        $service = PHOTO_BOL_PhotoService::getInstance();
		$userService = BOL_UserService::getInstance();
      #     $list = array() ;
        $list = $service->findPhotoList( "latest", 1, 500);
      #  $list = array_reverse($list);
        $images = array();

        foreach ( $list as $img )
        {

		    if($service->findPhotoOwner($img['id']) != OW::getUser()->getId()) continue;
		    $album =  $albumService->findAlbumById($img['albumId']);

            $images[] = array(
                'dto' => $service->findPhotoById($img['id']),

				'data' => $service->getPhotoData($img['id']),     #getPhotoData method will add , please see step 3!!

                'url' => $service->getPhotoPreviewUrl($img['id']),
                'sel' => false,
            );
        }
		#echo $images[0]['data']->name;

        $this->assign('images', $images);
        $this->assign('id', $params['id']);	

	}

2) this file is the view, just copy the media_panel_gallery.html and named as /ow_system_plugins/base/views/controllers/media_panel_photogal.html

3) add one method in /ow_plugins/photo/bol/photo_service.php

this is optional , if you don’t add this method , please note the first step. You need some change.

	/**
	new added
	*/
	public function getPhotoData( $id)
    {
        $albumService = PHOTO_BOL_PhotoAlbumService::getInstance();
		$photoObject = $this->findPhotoById($id);

		$album =  $albumService->findAlbumById($photoObject->albumId);

		$data -> name = "pic under this album:".$album->name;

		return $data;
    }

一条评论

  1. Ralph.Maydelle说道:

    deleted comments

发表评论

电子邮件地址不会被公开。 必填项已用*标注