當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Images::getInstance方法代碼示例

本文整理匯總了PHP中Images::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Images::getInstance方法的具體用法?PHP Images::getInstance怎麽用?PHP Images::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Images的用法示例。


在下文中一共展示了Images::getInstance方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: XoopsMediaUploader

        }
    } else {
        if (!$imgcatperm_handler->checkRight('imgcat_write', $imgcat_id, FixedGroups::ANONYMOUS)) {
            $error = _CO_PUBLISHER_IMAGE_CAT_NOPERM;
        }
    }
}
$image = null;
if ($error == false) {
    $uploader = new XoopsMediaUploader(\XoopsBaseConfig::get('uploads-path') . '/images', array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'), $imgcat->getVar('imgcat_maxsize'), $imgcat->getVar('imgcat_maxwidth'), $imgcat->getVar('imgcat_maxheight'));
    $uploader->setPrefix('img');
    if ($uploader->fetchMedia('publisher_upload_file')) {
        if (!$uploader->upload()) {
            $error = implode("<br>", $uploader->getErrors(false));
        } else {
            $image_handler = Images::getInstance()->getHandlerImages();
            $image = $image_handler->create();
            $image->setVar('image_name', $uploader->getSavedFileName());
            $image->setVar('image_nicename', $image_nicename);
            $image->setVar('image_mimetype', $uploader->getMediaType());
            $image->setVar('image_created', time());
            $image->setVar('image_display', 1);
            $image->setVar('image_weight', 0);
            $image->setVar('imgcat_id', $imgcat_id);
            if ($imgcat->getVar('imgcat_storetype') === 'db') {
                $fp = @fopen($uploader->getSavedDestination(), 'rb');
                $fbinary = @fread($fp, filesize($uploader->getSavedDestination()));
                @fclose($fp);
                $image->setVar('image_body', $fbinary);
                @unlink($uploader->getSavedDestination());
            }
開發者ID:ming-hai,項目名稱:XoopsCore,代碼行數:31,代碼來源:ajax_upload.php

示例2: __construct

    /**
     * @param PublisherItem $obj
     */
    public function __construct(PublisherItem $obj)
    {
        $xoops = Xoops::getInstance();
        $publisher = Publisher::getInstance();
        $allowed_editors = PublisherUtils::getEditors($publisher->getPermissionHandler()->getGrantedItems('editors'));
        $group = $xoops->getUserGroups();
        parent::__construct('title', 'form', $xoops->getEnv('PHP_SELF'));
        $this->setExtra('enctype="multipart/form-data"');
        $tabtray = new Xoops\Form\TabTray('', 'uniqueid', $xoops->getModuleConfig('jquery_theme', 'system'));
        $mainTab = new Xoops\Form\Tab(_CO_PUBLISHER_TAB_MAIN, 'maintab');
        // Category
        $category_select = new Xoops\Form\Select(_CO_PUBLISHER_CATEGORY, 'categoryid', $obj->getVar('categoryid', 'e'));
        $category_select->setDescription(_CO_PUBLISHER_CATEGORY_DSC);
        $category_select->addOptionArray($publisher->getCategoryHandler()->getCategoriesForSubmit());
        $mainTab->addElement($category_select);
        // ITEM TITLE
        $mainTab->addElement(new Xoops\Form\Text(_CO_PUBLISHER_TITLE, 'title', 50, 255, $obj->getVar('title', 'e')), true);
        // SUBTITLE
        if ($this->_isGranted(_PUBLISHER_SUBTITLE)) {
            $mainTab->addElement(new Xoops\Form\Text(_CO_PUBLISHER_SUBTITLE, 'subtitle', 50, 255, $obj->getVar('subtitle', 'e')));
        }
        // SHORT URL
        if ($this->_isGranted(_PUBLISHER_ITEM_SHORT_URL)) {
            $text_short_url = new Xoops\Form\Text(_CO_PUBLISHER_ITEM_SHORT_URL, 'item_short_url', 50, 255, $obj->getVar('short_url', 'e'));
            $text_short_url->setDescription(_CO_PUBLISHER_ITEM_SHORT_URL_DSC);
            $mainTab->addElement($text_short_url);
        }
        // TAGS
        if ($xoops->isActiveModule('tag') && $this->_isGranted(_PUBLISHER_ITEM_TAG)) {
            include_once \XoopsBaseConfig::get('root-path') . '/modules/tag/include/formtag.php';
            $text_tags = new Xoops\Form\Tag('item_tag', 60, 255, $obj->getVar('item_tag', 'e'), 0);
            $mainTab->addElement($text_tags);
        }
        // SELECT EDITOR
        $nohtml = false;
        if (count($allowed_editors) == 1) {
            $editor = $allowed_editors[0];
        } else {
            if (count($allowed_editors) > 0) {
                $editor = @$_POST['editor'];
                if (!empty($editor)) {
                    PublisherUtils::setCookieVar('publisher_editor', $editor);
                } else {
                    $editor = PublisherUtils::getCookieVar('publisher_editor');
                    if (empty($editor) && $xoops->isUser()) {
                        $editor = $xoops->user->getVar('publisher_editor');
                        // Need set through user profile
                    }
                }
                $editor = empty($editor) || !in_array($editor, $allowed_editors) ? $publisher->getConfig('submit_editor') : $editor;
                $form_editor = new Xoops\Form\SelectEditor($this, 'editor', $editor, $nohtml, $allowed_editors);
                $mainTab->addElement($form_editor);
            } else {
                $editor = $publisher->getConfig('submit_editor');
            }
        }
        $editor_configs = array();
        $editor_configs["rows"] = !$publisher->getConfig('submit_editor_rows') ? 35 : $publisher->getConfig('submit_editor_rows');
        $editor_configs["cols"] = !$publisher->getConfig('submit_editor_cols') ? 60 : $publisher->getConfig('submit_editor_cols');
        $editor_configs["width"] = !$publisher->getConfig('submit_editor_width') ? "100%" : $publisher->getConfig('submit_editor_width');
        $editor_configs["height"] = !$publisher->getConfig('submit_editor_height') ? "400px" : $publisher->getConfig('submit_editor_height');
        // SUMMARY
        if ($this->_isGranted(_PUBLISHER_SUMMARY)) {
            // Description
            //$summary_text = new Xoops\Form\TextArea(_CO_PUBLISHER_SUMMARY, 'summary', $obj->getVar('summary', 'e'), 7, 60);
            $editor_configs["name"] = "summary";
            $editor_configs["value"] = $obj->getVar('summary', 'e');
            $summary_text = new Xoops\Form\Editor(_CO_PUBLISHER_SUMMARY, $editor, $editor_configs, $nohtml, $onfailure = null);
            $summary_text->setDescription(_CO_PUBLISHER_SUMMARY_DSC);
            $mainTab->addElement($summary_text);
        }
        // BODY
        $editor_configs["name"] = "body";
        $editor_configs["value"] = $obj->getVar('body', 'e');
        $body_text = new Xoops\Form\Editor(_CO_PUBLISHER_BODY, $editor, $editor_configs, $nohtml, $onfailure = null);
        $body_text->setDescription(_CO_PUBLISHER_BODY_DSC);
        $mainTab->addElement($body_text);
        // VARIOUS OPTIONS
        if ($this->_isGranted(_PUBLISHER_DOHTML) || $this->_isGranted(_PUBLISHER_DOSMILEY) || $this->_isGranted(_PUBLISHER_DOXCODE) || $this->_isGranted(_PUBLISHER_DOIMAGE) || $this->_isGranted(_PUBLISHER_DOLINEBREAK)) {
            if ($this->_isGranted(_PUBLISHER_DOHTML)) {
                $html_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOHTML, 'dohtml', $obj->getVar('dohtml'));
                $mainTab->addElement($html_radio);
            }
            if ($this->_isGranted(_PUBLISHER_DOSMILEY)) {
                $smiley_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOSMILEY, 'dosmiley', $obj->getVar('dosmiley'));
                $mainTab->addElement($smiley_radio);
            }
            if ($this->_isGranted(_PUBLISHER_DOXCODE)) {
                $xcode_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOXCODE, 'doxcode', $obj->getVar('doxcode'));
                $mainTab->addElement($xcode_radio);
            }
            if ($this->_isGranted(_PUBLISHER_DOIMAGE)) {
                $image_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOIMAGE, 'doimage', $obj->getVar('doimage'));
                $mainTab->addElement($image_radio);
            }
            if ($this->_isGranted(_PUBLISHER_DOLINEBREAK)) {
                $linebreak_radio = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_DOLINEBREAK, 'dolinebreak', $obj->getVar('dobr'));
//.........這裏部分代碼省略.........
開發者ID:redmexico,項目名稱:XoopsCore,代碼行數:101,代碼來源:item.php

示例3: getImages

 /**
  * @return mixed
  */
 public function getImages()
 {
     static $ret;
     $xoops = Xoops::getInstance();
     if (!$xoops->isActiveModule('images')) {
         return array();
     }
     $itemid = $this->getVar('itemid');
     if (!isset($ret[$itemid])) {
         $ret[$itemid]['main'] = '';
         $ret[$itemid]['others'] = array();
         $images_ids = array();
         $image = $this->getVar('image');
         $images = $this->getVar('images');
         if ($images != '') {
             $images_ids = explode('|', $images);
         }
         if ($image > 0) {
             $images_ids = array_merge($images_ids, array($image));
         }
         $imageObjs = array();
         if (count($images_ids) > 0) {
             $image_handler = Images::getInstance()->getHandlerImages();
             $criteria = new CriteriaCompo(new Criteria('image_id', '(' . implode(',', $images_ids) . ')', 'IN'));
             $imageObjs = $image_handler->getObjects($criteria, true);
             unset($criteria);
         }
         foreach ($imageObjs as $id => $imageObj) {
             if ($id == $image) {
                 $ret[$itemid]['main'] = $imageObj;
             } else {
                 $ret[$itemid]['others'][] = $imageObj;
             }
             unset($imageObj);
         }
         unset($imageObjs);
     }
     return $ret[$itemid];
 }
開發者ID:ming-hai,項目名稱:XoopsCore,代碼行數:42,代碼來源:item.php

示例4: dirname

 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
use Xoops\Core\Request;
/**
 * Module Images
 *
 * @copyright       XOOPS Project (http://xoops.org)
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package         Images
 * @since           2.6.0
 * @version         $Id$
 */
include dirname(dirname(__DIR__)) . '/mainfile.php';
$xoops = Xoops::getInstance();
$helper = Images::getInstance();
$helper->loadLanguage('main');
$helper->loadLanguage('admin');
$op = Request::getCmd('op', 'list');
$target = Request::getWord('target', '');
$imgcat_id = Request::getInt('imgcat_id', 0);
$start = Request::getInt('start', 0);
if (empty($target)) {
    exit('Target not set');
}
$groups = $xoops->getUserGroups();
$xoops->simpleHeader();
$xoopsTpl = new XoopsTpl();
$xoopsTpl->assign('sitename', htmlspecialchars($xoops->getConfig('sitename'), ENT_QUOTES));
$xoopsTpl->assign('target', htmlspecialchars($target, ENT_QUOTES));
switch ($op) {
開發者ID:RanLee,項目名稱:XoopsCore,代碼行數:31,代碼來源:imagemanager.php

示例5: buildImagesTab

    /**
     * Build the images tab
     *
     * @param PublisherItem      $obj       data source
     * @param ContainerInterface $imagesTab add elements to this tab/form
     *
     * @return void
     */
    private function buildImagesTab(PublisherItem $obj, ContainerInterface $imagesTab)
    {
        $xoops = Xoops::getInstance();
        $group = $xoops->getUserGroups();
        // IMAGE
        if ($this->isGranted(_PUBLISHER_IMAGE_ITEM)) {
            $imgcat_handler = Images::getInstance()->getHandlerCategories();
            $image_handler = Images::getInstance()->getHandlerImages();
            $objimages = $obj->getImages();
            $mainarray = is_object($objimages['main']) ? array($objimages['main']) : array();
            $mergedimages = array_merge($mainarray, $objimages['others']);
            $objimage_array = array();
            /* @var $imageObj ImagesImage */
            foreach ($mergedimages as $imageObj) {
                $objimage_array[$imageObj->getVar('image_name')] = $imageObj->getVar('image_nicename');
            }
            $catlist = $imgcat_handler->getListByPermission($group, 'imgcat_read', 1);
            $catids = array_keys($catlist);
            $imageObjs = array();
            if (!empty($catids)) {
                $criteria = new CriteriaCompo(new Criteria('imgcat_id', '(' . implode(',', $catids) . ')', 'IN'));
                $criteria->add(new Criteria('image_display', 1));
                $criteria->setSort('image_nicename');
                $criteria->setOrder('ASC');
                $imageObjs = $image_handler->getObjects($criteria, true);
                unset($criteria);
            }
            $image_array = array();
            foreach ($imageObjs as $imageObj) {
                $image_array[$imageObj->getVar('image_name')] = $imageObj->getVar('image_nicename');
            }
            $image_array = array_diff($image_array, $objimage_array);
            $image_select = new Xoops\Form\Select('', 'image_notused', '', 5);
            $image_select->addOptionArray($image_array);
            $image_select->set('onchange', 'showImgSelected("image_display", "image_notused", "uploads/", "", "' . \XoopsBaseConfig::get('url') . '")');
            unset($image_array);
            $image_select2 = new Xoops\Form\Select('', 'image_item', '', 5, true);
            $image_select2->addOptionArray($objimage_array);
            $image_select2->set('onchange', 'publisher_updateSelectOption("image_item", "image_featured"), ' . 'showImgSelected("image_display", "image_item", "uploads/", "", "' . \XoopsBaseConfig::get('url') . '");');
            $buttonadd = new Xoops\Form\Button('', 'buttonadd', _CO_PUBLISHER_ADD);
            $buttonadd->set('onclick', 'publisher_appendSelectOption("image_notused", "image_item"), ' . 'publisher_updateSelectOption("image_item", "image_featured");');
            $buttonremove = new Xoops\Form\Button('', 'buttonremove', _CO_PUBLISHER_REMOVE);
            $buttonremove->set('onclick', 'publisher_appendSelectOption("image_item", "image_notused"), ' . 'publisher_updateSelectOption("image_item", "image_featured");');
            $opentable = new Xoops\Form\Label('', "<table><tr><td>");
            $addcol = new Xoops\Form\Label('', "</td><td>");
            $addbreak = new Xoops\Form\Label('', "<br />");
            $closetable = new Xoops\Form\Label('', "</td></tr></table>");
            $xoops->theme()->addScript(PUBLISHER_URL . '/js/ajaxupload.3.9.js');
            //todo, find replacement for error class
            $js_data = new Xoops\Form\Label('', '
<script type= "text/javascript">/*<![CDATA[*/
$(document).ready(function(){
    var button = $("#publisher_upload_button"), interval;
    new AjaxUpload(button,{
        action: "' . PUBLISHER_URL . '/include/ajax_upload.php", // I disabled uploads in this example for security reasons
        responseType: "text/html",
        name: "publisher_upload_file",
        onSubmit : function(file, ext){
            // change button text, when user selects file
            $("#publisher_upload_message").html(" ");
            button.html("<img src=\'' . PUBLISHER_URL . '/images/loadingbar.gif\'/>"); this.setData({
                "image_nicename": $("#image_nicename").val(),
                "imgcat_id" : $("#imgcat_id").val()
            });
            // If you want to allow uploading only 1 file at time,
            // you can disable upload button
            this.disable();
            interval = window.setInterval(function(){
            }, 200);
        },
        onComplete: function(file, response){
            button.text("' . _CO_PUBLISHER_IMAGE_UPLOAD_NEW . '");
            window.clearInterval(interval);
            // enable upload button
            this.enable();
            // add file to the list
            var result = eval(response);
            if (result[0] == "success") {
                 $("#image_item").append("<option value=\'" + result[1] + "\' selected=\'selected\'>" + result[2] + "</option>");
                 publisher_updateSelectOption(\'image_item\', \'image_featured\');
                 showImgSelected(\'image_display\', \'image_item\', \'uploads/\', \'\', \'' . \XoopsBaseConfig::get('url') . '\')
            } else {
                 $("#publisher_upload_message").html("<div class=\'errorMsg\'>" + result[1] + "</div>");
            }
        }
    });
});
/*]]>*/</script>
');
            $messages = new Xoops\Form\Label('', "<div id='publisher_upload_message'></div>");
            $button = new Xoops\Form\Label('', "<div id='publisher_upload_button'>" . _CO_PUBLISHER_IMAGE_UPLOAD_NEW . "</div>");
            $nicename = new Xoops\Form\Text('', 'image_nicename', 30, 30, _CO_PUBLISHER_IMAGE_NICENAME);
//.........這裏部分代碼省略.........
開發者ID:ming-hai,項目名稱:XoopsCore,代碼行數:101,代碼來源:item.php


注:本文中的Images::getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。