当前位置: 首页>>代码示例>>PHP>>正文


PHP BlockInstance::commit方法代码示例

本文整理汇总了PHP中BlockInstance::commit方法的典型用法代码示例。如果您正苦于以下问题:PHP BlockInstance::commit方法的具体用法?PHP BlockInstance::commit怎么用?PHP BlockInstance::commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BlockInstance的用法示例。


在下文中一共展示了BlockInstance::commit方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: xmldb_core_upgrade


//.........这里部分代码省略.........
    }
    if ($oldversion < 2014032400) {
        $table = new XMLDBTable('group');
        $field = new XMLDBField('sendnow');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
        add_field($table, $field);
    }
    if ($oldversion < 2014032500) {
        $table = new XMLDBTable('usr');
        $field = new XMLDBField('probation');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null, null, 0);
        add_field($table, $field);
    }
    if ($oldversion < 2014032600) {
        set_config('watchlistnotification_delay', 20);
        if (!table_exists(new XMLDBTable('watchlist_queue'))) {
            $table = new XMLDBTable('watchlist_queue');
            $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
            $table->addFieldInfo('usr', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
            $table->addFieldInfo('block', XMLDB_TYPE_INTEGER, 10, null, false);
            $table->addFieldInfo('view', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
            $table->addFieldInfo('changed_on', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
            $table->addKeyInfo('viewfk', XMLDB_KEY_FOREIGN, array('view'), 'view', array('id'));
            $table->addKeyInfo('blockfk', XMLDB_KEY_FOREIGN, array('block'), 'block_instance', array('id'));
            $table->addKeyInfo('usrfk', XMLDB_KEY_FOREIGN, array('usr'), 'usr', array('id'));
            $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
            create_table($table);
        }
        // new event type: delete blockinstance
        $e = new stdClass();
        $e->name = 'deleteblockinstance';
        ensure_record_exists('event_type', $e, $e);
        // install the core event subscriptions
        $subs = array(array('event' => 'blockinstancecommit', 'callfunction' => 'watchlist_record_changes'), array('event' => 'deleteblockinstance', 'callfunction' => 'watchlist_block_deleted'), array('event' => 'saveartefact', 'callfunction' => 'watchlist_record_changes'), array('event' => 'saveview', 'callfunction' => 'watchlist_record_changes'));
        foreach ($subs as $sub) {
            ensure_record_exists('event_subscription', (object) $sub, (object) $sub);
        }
        // install the cronjobs...
        $cron = new stdClass();
        $cron->callfunction = 'watchlist_process_notifications';
        $cron->minute = '*';
        $cron->hour = '*';
        $cron->day = '*';
        $cron->month = '*';
        $cron->dayofweek = '*';
        ensure_record_exists('cron', $cron, $cron);
    }
    if ($oldversion < 2014032700) {
        // Remove bad data created by the upload user via csv where users in no institution
        // have 'licensedefault' set causing an error
        execute_sql("DELETE FROM {usr_account_preference} WHERE FIELD = 'licensedefault' AND usr IN (\n                        SELECT u.id FROM {usr} u\n                        LEFT JOIN {usr_institution} ui ON ui.usr = u.id\n                        WHERE ui.institution = 'mahara' OR ui.institution is null\n                     )");
    }
    if ($oldversion < 2014040300) {
        // Figure out where the magicdb is, and stick with that.
        require_once get_config('libroot') . 'file.php';
        update_magicdb_path();
    }
    // Add id field and corresponding index to institution table.
    if ($oldversion < 2014040400) {
        $table = new XMLDBTable('institution');
        // Add id field.
        $field = new XMLDBField('id');
        if (!field_exists($table, $field)) {
            // Field.
            $field->setAttributes(XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null, null, 1, 'name');
            add_field($table, $field);
开发者ID:patkira,项目名称:mahara,代码行数:67,代码来源:upgrade.php

示例2: xmldb_blocktype_externalfeed_upgrade

function xmldb_blocktype_externalfeed_upgrade($oldversion = 0)
{
    if ($oldversion < 2008042101) {
        // We hit the 255 character limit for feed URLs
        if (is_postgres()) {
            execute_sql('ALTER TABLE {blocktype_externalfeed_data} ALTER COLUMN url TYPE TEXT');
        } else {
            if (is_mysql()) {
                // If 2 URLs > 255 chars have the same first 255 characters then mahara will error - this is a MySQL issue though, their unique key length limit is to blame
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} DROP KEY {blocextedata_url_uix}');
                // We have to remove then add the constraint again else the change will make MySQL cry
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} MODIFY COLUMN "url" text');
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} add unique {blocextedata_url_uix} (url(255))');
            }
        }
    }
    if ($oldversion < 2009121600) {
        if (is_mysql()) {
            // Make content column wider (TEXT is only 65kb in mysql)
            $table = new XMLDBTable('blocktype_externalfeed_data');
            $field = new XMLDBField('content');
            $field->setAttributes(XMLDB_TYPE_TEXT, "big", null, null);
            change_field_precision($table, $field);
        }
    }
    if ($oldversion < 2010073000) {
        execute_sql('
            UPDATE {blocktype_cron}
            SET minute = ?
            WHERE minute = ? AND hour = ? AND plugin = ? AND callfunction = ?', array('30', '0', '3', 'externalfeed', 'cleanup_feeds'));
    }
    if ($oldversion < 2011091400) {
        // Add columns for HTTP basic auth
        $table = new XMLDBTable('blocktype_externalfeed_data');
        $field1 = new XMLDBField('authuser');
        $field1->setAttributes(XMLDB_TYPE_TEXT);
        $field2 = new XMLDBField('authpassword');
        $field2->setAttributes(XMLDB_TYPE_TEXT);
        add_field($table, $field1);
        add_field($table, $field2);
        // Change unique constraint that's no longer valid
        $table = new XMLDBTable('blocktype_externalfeed_data');
        $index = new XMLDBIndex('url_uix');
        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('url'));
        drop_index($table, $index);
        if (is_postgres()) {
            $index = new XMLDBIndex('urlautautix');
            $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('url', 'authuser', 'authpassword'));
            add_index($table, $index);
        } else {
            if (is_mysql()) {
                // MySQL needs size limits when indexing text fields
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} ADD INDEX
                           {blocextedata_urlautaut_ix} (url(255), authuser(255), authpassword(255))');
            }
        }
    }
    if ($oldversion < 2011091401) {
        // Add columns for insecure SSL mode
        $table = new XMLDBTable('blocktype_externalfeed_data');
        $field = new XMLDBField('insecuresslmode');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
        add_field($table, $field);
    }
    if ($oldversion < 2012090700) {
        // Reset all feeds to reset themselves
        set_field('blocktype_externalfeed_data', 'lastupdate', db_format_timestamp('0'));
        safe_require('blocktype', 'externalfeed');
        call_static_method('PluginBlocktypeExternalfeed', 'refresh_feeds');
    }
    if ($oldversion < 2014041500) {
        log_debug('Cleaning up duplicate feeds in the externalfeed blocktype');
        log_debug('1. Find the duplicate feed urls');
        // Setting these to be empty strings instead of NULL will make our SQL a lot simpler in the next section
        execute_sql("update {blocktype_externalfeed_data} set authuser='' where authuser is null");
        execute_sql("update {blocktype_externalfeed_data} set authpassword='' where authpassword is null");
        if ($duplicatefeeds = get_records_sql_array("SELECT COUNT(url), url, authuser, authpassword FROM {blocktype_externalfeed_data} GROUP BY url, authuser, authpassword HAVING COUNT(url) > 1 ORDER BY url, authuser, authpassword", array())) {
            log_debug('2. Get all feed ids for the duplicated feed urls');
            // Use the 1st one found to be the feed id for the block instances that need updating
            $feedstoupdate = array();
            foreach ($duplicatefeeds as $feed) {
                $feedids = get_column('blocktype_externalfeed_data', 'id', 'url', $feed->url, 'authuser', $feed->authuser, 'authpassword', $feed->authpassword);
                $feedstoupdate[$feed->url] = $feedids;
            }
            log_debug('3. Updating blocks to use correct feed id');
            // Find the block instances using external feeds. Check to see if they are not using the 'true' id and update them accordingly
            require_once get_config('docroot') . 'blocktype/lib.php';
            $blockids = get_records_array('block_instance', 'blocktype', 'externalfeed', 'id ASC', 'id');
            foreach ($blockids as $blockid) {
                $blockinstance = new BlockInstance($blockid->id);
                $configdata = $blockinstance->get('configdata');
                if (!empty($configdata['feedid'])) {
                    foreach ($feedstoupdate as $url => $ids) {
                        foreach ($ids as $key => $id) {
                            if ($id == $configdata['feedid'] && $key != '0') {
                                $configdata['feedid'] = $ids[0];
                                $blockinstance->set('configdata', $configdata);
                                $blockinstance->set('dirty', true);
                                $blockinstance->commit();
                                break;
//.........这里部分代码省略.........
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:101,代码来源:upgrade.php

示例3: install_system_dashboard_view

/**
 * This function installs the site's default dashboard view
 *
 * @throws SystemException if the system dashboard view is already installed
 */
function install_system_dashboard_view()
{
    $viewid = get_field('view', 'id', 'owner', 0, 'type', 'dashboard');
    if ($viewid) {
        throw new SystemException('A system dashboard view already seems to be installed');
    }
    require_once get_config('libroot') . 'view.php';
    require_once get_config('docroot') . 'blocktype/lib.php';
    $view = View::create(array('type' => 'dashboard', 'owner' => 0, 'numcolumns' => 2, 'ownerformat' => FORMAT_NAME_PREFERREDNAME, 'title' => get_string('dashboardviewtitle', 'view'), 'template' => 1));
    $view->set_access(array(array('type' => 'loggedin')));
    $blocktypes = array(array('blocktype' => 'newviews', 'title' => get_string('title', 'blocktype.newviews'), 'column' => 1, 'config' => array('limit' => 5)), array('blocktype' => 'myviews', 'title' => get_string('title', 'blocktype.myviews'), 'column' => 1, 'config' => null), array('blocktype' => 'inbox', 'title' => get_string('recentactivity'), 'column' => 2, 'config' => array('feedback' => true, 'groupmessage' => true, 'institutionmessage' => true, 'maharamessage' => true, 'usermessage' => true, 'viewaccess' => true, 'watchlist' => true, 'maxitems' => '5')), array('blocktype' => 'inbox', 'title' => get_string('topicsimfollowing'), 'column' => 2, 'config' => array('newpost' => true, 'maxitems' => '5')));
    $installed = get_column_sql('SELECT name FROM {blocktype_installed}');
    $weights = array(1 => 0, 2 => 0);
    foreach ($blocktypes as $blocktype) {
        if (in_array($blocktype['blocktype'], $installed)) {
            $weights[$blocktype['column']]++;
            $newblock = new BlockInstance(0, array('blocktype' => $blocktype['blocktype'], 'title' => $blocktype['title'], 'view' => $view->get('id'), 'column' => $blocktype['column'], 'order' => $weights[$blocktype['column']], 'configdata' => $blocktype['config']));
            $newblock->commit();
        }
    }
    return $view->get('id');
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:27,代码来源:user.php

示例4: render_instance

 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $THEME;
     $configdata = $instance->get('configdata');
     $width = !empty($configdata['width']) ? hsc($configdata['width']) : 0;
     $height = !empty($configdata['height']) ? hsc($configdata['height']) : 0;
     if (!isset($configdata['html'])) {
         if (!isset($configdata['videoid'])) {
             return '';
         }
         // This is a legacy block where videoid contains only a url, so generate embed/iframe code.
         $url = $configdata['videoid'];
         if (isset($configdata['type']) && $configdata['type'] == 'embed') {
             $configdata['html'] = $configdata['videoid'] = self::embed_code($url, $width, $height);
             unset($configdata['type']);
         } else {
             if (isset($configdata['type']) && $configdata['type'] == 'iframe') {
                 $configdata['html'] = $configdata['videoid'] = self::iframe_code($url, $width, $height);
                 unset($configdata['type']);
             } else {
                 if ($urldata = self::process_url($url, $width, $height)) {
                     $configdata = $urldata;
                 } else {
                     $configdata['html'] = '';
                     // We can't do anything with this url
                 }
             }
         }
         $instance->set('configdata', $configdata);
         $instance->commit();
     }
     if (empty($configdata['html'])) {
         return '';
     }
     $smarty = smarty_core();
     // don't load html for auto retracted blocks to speed up page load time
     if (!empty($configdata['retractedonload']) && !$editing) {
         $smarty->assign('html', '<div id="block_' . $instance->get('id') . '_waiting">' . get_string('loading', 'mahara') . '</div>');
         $is_src = preg_match('/src=\\"(.*?)\\"/', $configdata['html'], $src);
         $is_width = preg_match('/ width=\\"(.*?)\\"/', $configdata['html'], $widthmatch);
         $is_height = preg_match('/ height=\\"(.*?)\\"/', $configdata['html'], $heightmatch);
         if ($is_src) {
             $smarty->assign('jsurl', $src[1]);
             // check if is embed rather than iframe
             $is_flashvars = preg_match('/flashvars=\\"(.*?)\\"/', $configdata['html'], $flashvars);
             if ($is_flashvars) {
                 $smarty->assign('jsflashvars', $flashvars[1]);
             }
             if (empty($width) && !empty($widthmatch)) {
                 $width = $widthmatch[1];
             }
             if (empty($height) && !empty($heightmatch)) {
                 $height = $heightmatch[1];
             }
         } else {
             // need to fall back to handling this normally
             $smarty->assign('html', $configdata['html']);
         }
     } else {
         $smarty->assign('html', $configdata['html']);
     }
     $smarty->assign('width', $width);
     $smarty->assign('height', $height);
     $smarty->assign('blockid', $instance->get('id'));
     return $smarty->fetch('blocktype:externalvideo:content.tpl');
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:66,代码来源:lib.php

示例5: moveblockinstance

 /**
  * moves a block instance to a specified location
  *
  * @param array $values parameters for this function
  *                      id     => int of block instance to move
  *                      row      => int current row
  *                      column => int column to move to
  *                      order  => position in new column to insert at
  */
 public function moveblockinstance($values)
 {
     $requires = array('id', 'row', 'column', 'order');
     foreach ($requires as $require) {
         if (!array_key_exists($require, $values) || empty($values[$require])) {
             throw new ParamOutOfRangeException(get_string('missingparam' . $require, 'error'));
         }
     }
     require_once get_config('docroot') . 'blocktype/lib.php';
     $bi = new BlockInstance($values['id']);
     // Check if the block_instance belongs to this view
     if ($bi->get('view') != $this->get('id')) {
         throw new AccessDeniedException(get_string('blocknotinview', 'view', $bi->get('id')));
     }
     db_begin();
     // moving within the same column and row
     if ($bi->get('row') == $values['row'] && $bi->get('column') == $values['column']) {
         if ($values['order'] == $bi->get('order') + 1 || $values['order'] == $bi->get('order') - 1) {
             // we're switching two, it's a bit different
             // set the one we're moving to out of range (to 0)
             // double quotes required for field names to avoid exception
             set_field_select('block_instance', 'order', 0, '"view" = ? AND "row" = ? AND "column" = ? AND "order" = ?', array($this->get('id'), $values['row'], $values['column'], $values['order']));
             // set the new order
             set_field_select('block_instance', 'order', $values['order'], '"view" = ? AND "row" = ? AND "column" = ? AND "order" = ?', array($this->get('id'), $values['row'], $values['column'], $bi->get('order')));
             // move the old one back to where the moving one was.
             set_field_select('block_instance', 'order', $bi->get('order'), '"view" = ? AND "row" = ? AND "column" = ? AND "order" = ?', array($this->get('id'), $values['row'], $values['column'], 0));
             // and set it in the object for good measure.
             $bi->set('order', $values['order']);
         } else {
             if ($values['order'] == $this->get_current_max_order($values['row'], $values['column'])) {
                 // moving to the very bottom
                 set_field_select('block_instance', 'order', 0, '"view" = ? AND "row" = ? AND "column" = ? AND "order" = ?', array($this->get('id'), $values['row'], $values['column'], $bi->get('order')));
                 $this->shuffle_helper('order', 'down', '>=', $bi->get('order'), '"column" = ? AND "row" = ?', array($bi->get('column'), $values['row']));
                 set_field_select('block_instance', 'order', $values['order'], '"order" = ? AND "view" = ? AND "row" = ? AND "column" = ?', array(0, $this->get('id'), $values['row'], $values['column']));
                 $bi->set('order', $values['order']);
             } else {
                 $this->shuffle_cell($values['row'], $bi->get('column'), $values['order'], $bi->get('order'));
                 if ($bi->get('order') < $values['order']) {
                     // When moving a block down within a column, the final order is one less
                     // than the 'desired' order because of the empty space created when the
                     // block gets taken out of its original spot.
                     $values['order'] -= 1;
                 }
             }
         }
     } else {
         // first figure out if we've asked to add it somewhere sensible
         // eg if we're moving a low down block into an empty column
         $newmax = $this->get_current_max_order($values['row'], $values['column']);
         if ($values['order'] > $newmax + 1) {
             $values['order'] = $newmax + 1;
         }
         // remove it from the old column
         $this->shuffle_cell($bi->get('row'), $bi->get('column'), null, $bi->get('order'));
         // and make a hole in the new column
         $this->shuffle_cell($values['row'], $values['column'], $values['order']);
     }
     $bi->set('column', $values['column']);
     $bi->set('row', $values['row']);
     $bi->set('order', $values['order']);
     $bi->commit();
     $this->dirtycolumns[$values['row']][$bi->get('column')] = 1;
     $this->dirtycolumns[$values['row']][$values['column']] = 1;
     db_commit();
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:74,代码来源:view.php

示例6: install_system_grouphomepage_view

/**
 * install the group homepage view
 * This creates a template at system level
 * which is subsequently copied to group hompages
 *
 * @return int the id of the new template
 */
function install_system_grouphomepage_view()
{
    $dbtime = db_format_timestamp(time());
    // create a system template for group homepage views
    require_once get_config('libroot') . 'view.php';
    $view = View::create(array('type' => 'grouphomepage', 'owner' => 0, 'numcolumns' => 2, 'numrows' => 1, 'columnsperrow' => array((object) array('row' => 1, 'columns' => 1)), 'template' => 1, 'title' => get_string('grouphomepage', 'view')));
    $view->set_access(array(array('type' => 'loggedin')));
    $blocktypes = array(array('blocktype' => 'groupinfo', 'title' => '', 'row' => 1, 'column' => 1, 'config' => null), array('blocktype' => 'recentforumposts', 'title' => '', 'row' => 1, 'column' => 1, 'config' => null), array('blocktype' => 'groupviews', 'title' => '', 'row' => 1, 'column' => 1, 'config' => array('showgroupviews' => 1, 'showsharedviews' => 1, 'showsharedcollections' => 1)), array('blocktype' => 'groupmembers', 'title' => '', 'row' => 1, 'column' => 1, 'config' => null));
    $installed = get_column_sql('SELECT name FROM {blocktype_installed}');
    $weights = array(1 => 0);
    foreach ($blocktypes as $blocktype) {
        if (in_array($blocktype['blocktype'], $installed)) {
            $weights[$blocktype['column']]++;
            $newblock = new BlockInstance(0, array('blocktype' => $blocktype['blocktype'], 'title' => $blocktype['title'], 'view' => $view->get('id'), 'row' => $blocktype['row'], 'column' => $blocktype['column'], 'order' => $weights[$blocktype['column']], 'configdata' => $blocktype['config']));
            $newblock->commit();
        }
    }
    return $view->get('id');
}
开发者ID:vohung96,项目名称:mahara,代码行数:26,代码来源:group.php

示例7: instance_config_form

 public static function instance_config_form(BlockInstance $instance)
 {
     global $USER;
     require_once 'license.php';
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'internal');
     $configdata = $instance->get('configdata');
     if (!($height = get_config('blockeditorheight'))) {
         $cfheight = param_integer('cfheight', 0);
         $height = $cfheight ? $cfheight * 0.7 : 150;
     }
     $otherblockcount = 0;
     $readonly = false;
     $text = '';
     $tags = '';
     $view = $instance->get_view();
     if (!empty($configdata['artefactid'])) {
         $artefactid = $configdata['artefactid'];
         try {
             $artefact = $instance->get_artefact_instance($artefactid);
             $readonly = $artefact->get('owner') !== $view->get('owner') || $artefact->get('group') !== $view->get('group') || $artefact->get('institution') !== $view->get('institution') || $artefact->get('locked') || !$USER->can_edit_artefact($artefact);
             $text = $artefact->get('description');
             $tags = $artefact->get('tags');
             if ($blocks = get_column('view_artefact', 'block', 'artefact', $artefactid)) {
                 $blocks = array_unique($blocks);
                 $otherblockcount = count($blocks) - 1;
             }
         } catch (ArtefactNotFoundException $e) {
             unset($artefactid);
         }
     }
     $otherblocksmsg = '<span id="textbox_blockcount">' . $otherblockcount . '</span>';
     $otherblocksmsg = get_string('textusedinotherblocks', 'blocktype.internal/textbox', $otherblocksmsg);
     $manageurl = get_config('wwwroot') . 'artefact/internal/notes.php';
     if ($group = $view->get('group')) {
         $manageurl .= '?group=' . $group;
     } else {
         if ($institution = $view->get('institution')) {
             $manageurl .= '?institution=' . $institution;
         }
     }
     // Update the attached files in block configdata as
     // it may change when attached files have been deleted
     $attachmentids = isset($artefact) ? $artefact->attachment_id_list() : false;
     if ($attachmentids !== false && isset($configdata['artefactids']) && $configdata['artefactids'] != $attachmentids) {
         $configdata['artefactids'] = $attachmentids;
         $instance->set('configdata', $configdata);
         $instance->commit();
     }
     $elements = array('otherblocksmsg' => array('type' => 'html', 'class' => 'message info' . ($otherblockcount && !$readonly ? '' : ' hidden'), 'value' => '<p class="alert alert-info">' . $otherblocksmsg . ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a></p>', 'help' => true), 'readonlymsg' => array('type' => 'html', 'class' => 'message info' . ($readonly ? '' : ' hidden'), 'value' => '<p class="alert alert-info">' . get_string('readonlymessage', 'blocktype.internal/textbox') . ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a></p>', 'help' => true), 'text' => array('type' => 'wysiwyg', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('blockcontent', 'blocktype.internal/textbox'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $text, 'rules' => array('maxlength' => 65536)), 'textreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('blockcontent', 'blocktype.internal/textbox'), 'value' => '<div id="instconf_textreadonly_display" class="well text-midtone">' . $text . '</div>'), 'makecopy' => array('type' => 'checkbox', 'class' => 'hidden', 'defaultvalue' => false), 'chooseartefact' => array('type' => 'html', 'value' => '<a id="chooseartefactlink" href="#" class="btn btn-default">' . get_string('usecontentfromanothertextbox1', 'blocktype.internal/textbox') . '</a>'), 'managenotes' => array('type' => 'html', 'class' => 'hidden text-right', 'value' => '<a href="' . $manageurl . '" target="_blank" class="pull-right">' . get_string('managealltextboxcontent1', 'blocktype.internal/textbox') . ' <span class="icon icon-arrow-right right"></span></a>'), 'artefactid' => self::artefactchooser_element(isset($artefactid) ? $artefactid : null), 'license' => license_form_el_basic(isset($artefact) ? $artefact : null), 'license_advanced' => license_form_el_advanced(isset($artefact) ? $artefact : null), 'licensereadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('license'), 'value' => '<div id="instconf_licensereadonly_display">' . (isset($artefact) ? render_license($artefact) : get_string('licensenone')) . '</div>'), 'allowcomments' => array('type' => 'switchbox', 'title' => get_string('allowcomments', 'artefact.comment'), 'defaultvalue' => !empty($artefact) ? $artefact->get('allowcomments') : 1), 'tags' => array('type' => 'tags', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('tags'), 'description' => get_string('tagsdescprofile'), 'defaultvalue' => $tags), 'tagsreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('tags'), 'value' => '<div id="instconf_tagsreadonly_display">' . (is_array($tags) ? hsc(join(', ', $tags)) : '') . '</div>'), 'artefactfieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('attachments', 'artefact.blog'), 'class' => 'last with-formgroup', 'elements' => array('artefactids' => self::filebrowser_element($instance, isset($configdata['artefactids']) ? $configdata['artefactids'] : null))));
     if ($readonly) {
         $elements['license']['class'] = 'hidden';
         $elements['license_advanced']['class'] = 'hidden';
     }
     return $elements;
 }
开发者ID:banterweb,项目名称:mahara,代码行数:56,代码来源:lib.php

示例8: create_from_template

 /**
  * Creates a Collection for the given user, based off a given template and other
  * Collection information supplied.
  *
  * Will set a default name of 'Copy of $collectiontitle' if name is not
  * specified in $collectiondata and $titlefromtemplate == false.
  *
  * @param array $collectiondata Contains information of the old collection, submitted in form
  * @param int $templateid The ID of the Collection to copy
  * @param int $userid     The user who has issued the command to create the
  *                        collection.
  * @param int $checkaccess Whether to check that the user can see the collection before copying it
  * @return array A list consisting of the new collection, the template collection and
  *               information about the copy - i.e. how many blocks and
  *               artefacts were copied
  * @throws SystemException under various circumstances, see the source for
  *                         more information
  */
 public static function create_from_template($collectiondata, $templateid, $userid = null, $checkaccess = true, $titlefromtemplate = false)
 {
     require_once get_config('libroot') . 'view.php';
     global $SESSION;
     if (is_null($userid)) {
         global $USER;
         $userid = $USER->get('id');
     }
     db_begin();
     $colltemplate = new Collection($templateid);
     $data = new StdClass();
     // Set a default name if one wasn't set in $collectiondata
     if ($titlefromtemplate) {
         $data->name = $colltemplate->get('name');
     } else {
         if (!isset($collectiondata['name'])) {
             $desiredname = $colltemplate->get('name');
             if (get_config('renamecopies')) {
                 $desiredname = get_string('Copyof', 'mahara', $desiredname);
             }
             $data->name = self::new_name($desiredname, (object) $collectiondata);
         } else {
             $data->name = $collectiondata['name'];
         }
     }
     $data->description = $colltemplate->get('description');
     $data->tags = $colltemplate->get('tags');
     $data->navigation = $colltemplate->get('navigation');
     if (!empty($collectiondata['group'])) {
         $data->group = $collectiondata['group'];
     } else {
         if (!empty($collectiondata['institution'])) {
             $data->institution = $collectiondata['institution'];
         } else {
             if (!empty($collectiondata['owner'])) {
                 $data->owner = $collectiondata['owner'];
             } else {
                 $data->owner = $userid;
             }
         }
     }
     $collection = self::save($data);
     $numcopied = array('pages' => 0, 'blocks' => 0, 'artefacts' => 0);
     $views = $colltemplate->get('views');
     $copyviews = array();
     foreach ($views['views'] as $v) {
         $values = array('new' => true, 'owner' => isset($data->owner) ? $data->owner : null, 'group' => isset($data->group) ? $data->group : null, 'institution' => isset($data->institution) ? $data->institution : null, 'usetemplate' => $v->view);
         list($view, $template, $copystatus) = View::create_from_template($values, $v->view, $userid, $checkaccess, $titlefromtemplate);
         if (isset($copystatus['quotaexceeded'])) {
             $SESSION->clear('messages');
             return array(null, $colltemplate, array('quotaexceeded' => true));
         }
         $copyviews['view_' . $view->get('id')] = true;
         $numcopied['blocks'] += $copystatus['blocks'];
         $numcopied['artefacts'] += $copystatus['artefacts'];
     }
     $numcopied['pages'] = count($views['views']);
     $collection->add_views($copyviews);
     // Update all the navigation blocks referring to this collection
     if ($viewids = get_column('collection_view', 'view', 'collection', $collection->get('id'))) {
         $navblocks = get_records_select_array('block_instance', 'view IN (' . join(',', array_fill(0, count($viewids), '?')) . ") AND blocktype = 'navigation'", $viewids);
         if ($navblocks) {
             safe_require('blocktype', 'navigation');
             foreach ($navblocks as $b) {
                 $bi = new BlockInstance($b->id, $b);
                 $configdata = $bi->get('configdata');
                 if (isset($configdata['collection']) && $configdata['collection'] == $templateid) {
                     $bi->set('configdata', array('collection' => $collection->get('id')));
                     $bi->commit();
                 }
             }
         }
     }
     db_commit();
     return array($collection, $colltemplate, $numcopied);
 }
开发者ID:agwells,项目名称:Mahara-1,代码行数:94,代码来源:collection.php

示例9: copy

 /**
  * Builds a new block instance as a copy of this one, taking into account
  * the Views being copied from and to.
  *
  * Blocktypes can decide whether they want to be copied to the new View. The
  * return value of this method should indicate whether the blocktype was
  * copied or not.
  *
  * @param View $view The view that this new blockinstance is being created for
  * @param View $template The view that this (the old) blockinstance comes from
  * @param array $artefactcopies Correspondence between original artefact IDs and IDs of copies
  * @return boolean Whether a new blockinstance was made or not.
  */
 public function copy(View $view, View $template, &$artefactcopies)
 {
     $blocktypeclass = generate_class_name('blocktype', $this->get('blocktype'));
     $configdata = $this->get('configdata');
     if (isset($configdata['copytype'])) {
         $copytype = $configdata['copytype'];
     } else {
         $copytype = call_static_method($blocktypeclass, 'default_copy_type');
     }
     $viewowner = $view->ownership();
     $templateowner = $template->ownership();
     $sameowner = $viewowner['type'] == $templateowner['type'] && $viewowner['id'] == $templateowner['id'];
     // Check to see if the block is allowed to be copied into the new View
     //
     // Note for later: this is Blockinstance->allowed_in_view. This
     // determines whether this blockinstance should be copied into a view.
     // This could be a different question from BlockType::allowed_in_view!
     // But for now they use the same method.
     if (!call_static_method($blocktypeclass, 'allowed_in_view', $view)) {
         return false;
     }
     if ($copytype == 'nocopy' && !$sameowner) {
         return false;
     }
     $newblock = new BlockInstance(0, array('blocktype' => $this->get('blocktype'), 'title' => $this->get('title'), 'view' => $view->get('id'), 'view_obj' => $view, 'row' => $this->get('row'), 'column' => $this->get('column'), 'order' => $this->get('order')));
     if ($sameowner || $copytype == 'reference') {
         $newblock->set('configdata', $configdata);
         $newblock->commit();
         return true;
     }
     $artefactids = get_column('view_artefact', 'artefact', 'block', $this->get('id'));
     if (!empty($artefactids) && $copytype == 'full') {
         // Copy artefacts & put the new artefact ids into the new block.
         // Artefacts may have children (defined using the parent column of the artefact table) and attachments (currently
         // only for blogposts).  If we copy an artefact we must copy all its descendents & attachments too.
         $descendants = artefact_get_descendants($artefactids);
         // We need the artefact instance before we can get its attachments
         $tocopy = array();
         $attachmentlists = array();
         $embedlists = array();
         foreach ($descendants as $d) {
             if (!isset($artefactcopies[$d])) {
                 $tocopy[$d] = artefact_instance_from_id($d);
                 // Get attachments.
                 $attachmentlists[$d] = $tocopy[$d]->attachment_id_list();
                 foreach ($attachmentlists[$d] as $a) {
                     if (!isset($artefactcopies[$a]) && !isset($tocopy[$a])) {
                         $tocopy[$a] = artefact_instance_from_id($a);
                     }
                 }
                 // Get embedded file artefacts
                 $embedlists[$d] = $tocopy[$d]->embed_id_list();
                 foreach ($embedlists[$d] as $a) {
                     if (!isset($artefactcopies[$a]) && !isset($tocopy[$a])) {
                         $tocopy[$a] = artefact_instance_from_id($a);
                     }
                 }
             }
         }
         // Copy all the artefacts we haven't copied yet
         foreach ($tocopy as $aid => $a) {
             // Save the id of the original artefact's parent
             $artefactcopies[$aid] = (object) array('oldid' => $aid, 'oldparent' => $a->get('parent'));
             if (!empty($attachmentlists[$aid])) {
                 $artefactcopies[$aid]->oldattachments = $attachmentlists[$aid];
             }
             if (!empty($embedlists[$aid])) {
                 $artefactcopies[$aid]->oldembeds = $embedlists[$aid];
             }
             $artefactcopies[$aid]->newid = $a->copy_for_new_owner($view->get('owner'), $view->get('group'), $view->get('institution'));
         }
         // Record new artefact ids in the new block
         if (isset($configdata['artefactid'])) {
             $configdata['artefactid'] = $artefactcopies[$configdata['artefactid']]->newid;
         }
         if (isset($configdata['artefactids'])) {
             foreach ($configdata['artefactids'] as &$oldid) {
                 $oldid = $artefactcopies[$oldid]->newid;
             }
         }
     } else {
         $configdata = call_static_method($blocktypeclass, 'rewrite_blockinstance_config', $view, $configdata);
     }
     // Rewrite the extra configuration of block
     $configdata = call_static_method($blocktypeclass, 'rewrite_blockinstance_extra_config', $view, $newblock, $configdata, $artefactcopies);
     $newblock->set('configdata', $configdata);
     $newblock->commit();
//.........这里部分代码省略.........
开发者ID:sarahjcotton,项目名称:mahara,代码行数:101,代码来源:lib.php

示例10: moveblockinstance

 /**
  * moves a block instance to a specified location
  *
  * @param array $values parameters for this function
  *                      id     => int of block instance to move
  *                      column => int column to move to
  *                      order  => position in new column to insert at
  */
 public function moveblockinstance($values)
 {
     $require = array('id', 'column', 'order');
     foreach ($require as $require) {
         if (!array_key_exists($require, $values) || empty($values[$require])) {
             throw new ParamOutOfRangeException(get_string('missingparam' . $require, 'error'));
         }
     }
     require_once get_config('docroot') . 'blocktype/lib.php';
     $bi = new BlockInstance($values['id']);
     db_begin();
     // moving within the same column
     if ($bi->get('column') == $values['column']) {
         if ($values['order'] == $bi->get('order') + 1 || $values['order'] == $bi->get('order') - 1) {
             // we're switching two, it's a bit different
             // set the one we're moving to out of range (to 0)
             set_field('block_instance', 'order', 0, 'view', $this->get('id'), 'column', $values['column'], 'order', $values['order']);
             // set the new order
             set_field('block_instance', 'order', $values['order'], 'view', $this->get('id'), 'column', $values['column'], 'order', $bi->get('order'));
             // move the old one back to where the moving one was.
             set_field('block_instance', 'order', $bi->get('order'), 'view', $this->get('id'), 'column', $values['column'], 'order', 0);
             // and set it in the object for good measure.
             $bi->set('order', $values['order']);
         } else {
             if ($values['order'] == $this->get_current_max_order($values['column'])) {
                 // moving to the very bottom
                 set_field('block_instance', 'order', 0, 'view', $this->get('id'), 'column', $values['column'], 'order', $bi->get('order'));
                 $this->shuffle_helper('order', 'down', '>=', $bi->get('order'), '"column" = ?', array($bi->get('column')));
                 set_field('block_instance', 'order', $values['order'], 'view', $this->get('id'), 'column', $values['column'], 'order', 0);
                 $bi->set('order', $values['order']);
             } else {
                 $this->shuffle_column($bi->get('column'), $values['order'], $bi->get('order'));
             }
         }
     } else {
         // first figure out if we've asked to add it somewhere sensible
         // eg if we're moving a low down block into an empty column
         $newmax = $this->get_current_max_order($values['column']);
         if ($values['order'] > $newmax + 1) {
             $values['order'] = $newmax + 1;
         }
         // remove it from the old column
         $this->shuffle_column($bi->get('column'), null, $bi->get('order'));
         // and make a hole in the new column
         $this->shuffle_column($values['column'], $values['order']);
     }
     $bi->set('column', $values['column']);
     $bi->set('order', $values['order']);
     $bi->commit();
     $this->dirtycolumns[$bi->get('column')] = 1;
     $this->dirtycolumns[$values['column']] = 1;
     db_commit();
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:61,代码来源:view.php

示例11: editnote_submit

function editnote_submit(Pieform $form, array $values)
{
    global $SESSION, $artefact, $goto;
    require_once 'embeddedimage.php';
    db_begin();
    $artefact->set('title', $values['title']);
    $newdescription = EmbeddedImage::prepare_embedded_images($values['description'], 'textbox', $artefact->get('id'), $artefact->get('group'));
    $artefact->set('description', $newdescription);
    $artefact->set('tags', $values['tags']);
    $artefact->set('allowcomments', (int) $values['allowcomments']);
    if (isset($values['perms'])) {
        $artefact->set('rolepermissions', $values['perms']);
        $artefact->set('dirty', true);
    }
    if (get_config('licensemetadata')) {
        $artefact->set('license', $values['license']);
        $artefact->set('licensor', $values['licensor']);
        $artefact->set('licensorurl', $values['licensorurl']);
    }
    $artefact->commit();
    // Attachments
    $old = $artefact->attachment_id_list();
    $new = is_array($values['filebrowser']) ? $values['filebrowser'] : array();
    if (!empty($new) || !empty($old)) {
        foreach ($old as $o) {
            if (!in_array($o, $new)) {
                try {
                    $artefact->detach($o);
                } catch (ArtefactNotFoundException $e) {
                }
            }
        }
        foreach ($new as $n) {
            if (!in_array($n, $old)) {
                try {
                    $artefact->attach($n);
                } catch (ArtefactNotFoundException $e) {
                }
            }
        }
    }
    // need to update the block_instances where this artefact is used - so they have
    // the correct configuration artefactids
    if ($blocks = get_column('view_artefact', 'block', 'artefact', $artefact->get('id'))) {
        require_once get_config('docroot') . 'blocktype/lib.php';
        foreach ($blocks as $block) {
            $bi = new BlockInstance($block);
            $configdata = $bi->get('configdata');
            $configdata['artefactids'] = $new;
            $bi->set('configdata', $configdata);
            $bi->commit();
        }
    }
    db_commit();
    $result = array('error' => false, 'message' => get_string('noteupdated', 'artefact.internal'), 'goto' => $goto);
    if ($form->submitted_by_js()) {
        // Redirect back to the note page from within the iframe
        $SESSION->add_ok_msg($result['message']);
        $form->json_reply(PIEFORM_OK, $result, false);
    }
    $form->reply(PIEFORM_OK, $result);
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:62,代码来源:editnote.php

示例12: import_rewrite_blockinstance_relationships_leap

 /**
  * After a leap2a import, rewrite the block instance's collection ID to the collection's new ID.
  * (If the collection was part of this import. If it's not, just remove it.)
  *
  * @param int $blockinstanceid
  * @param PluginLeapImport $importer
  */
 public static function import_rewrite_blockinstance_relationships_leap($blockinstanceid, $importer)
 {
     $bi = new BlockInstance($blockinstanceid);
     $configdata = $bi->get('configdata');
     // Rewrite the collection ID from the old one to the new one.
     if (isset($configdata['collection'])) {
         $oldcollectionid = $configdata['collection'];
         // Backwards-compatibility for Leap2a files before we started rewriting the collection ID
         if (strpos($oldcollectionid, 'portfolio:collection') !== 0) {
             $oldcollectionid = 'portfolio:collection' . (int) $oldcollectionid;
         }
         if (isset($importer->collectionids[$oldcollectionid])) {
             // If the collection was present in this import, point to its new ID
             $configdata['collection'] = $importer->collectionids[$oldcollectionid];
         } else {
             // If the collection was not present, then deactivate this block
             // TODO: Make some guesses about what it should point at?
             unset($configdata['collection']);
         }
     }
     $bi->set('configdata', $configdata);
     $bi->commit();
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:30,代码来源:lib.php

示例13: instance_config_form

 public static function instance_config_form(BlockInstance $instance)
 {
     global $USER;
     safe_require('artefact', 'file');
     $instance->set('artefactplugin', 'internal');
     $configdata = $instance->get('configdata');
     if (!($height = get_config('blockeditorheight'))) {
         $cfheight = param_integer('cfheight', 0);
         $height = $cfheight ? $cfheight * 0.7 : 150;
     }
     $otherblockcount = 0;
     $readonly = false;
     $text = '';
     $information = '';
     $literature = $configdata['literature'];
     $view = $instance->get_view();
     if (!empty($configdata['artefactid'])) {
         $artefactid = $configdata['artefactid'];
         try {
             $artefact = $instance->get_artefact_instance($artefactid);
             $readonly = $artefact->get('owner') !== $view->get('owner') || $artefact->get('group') !== $view->get('group') || $artefact->get('institution') !== $view->get('institution') || $artefact->get('locked') || !$USER->can_edit_artefact($artefact);
             $text = $artefact->get('note');
             $information = $artefact->get('description');
             if ($blocks = get_column('view_artefact', 'block', 'artefact', $artefactid)) {
                 $blocks = array_unique($blocks);
                 $otherblockcount = count($blocks) - 1;
             }
         } catch (ArtefactNotFoundException $e) {
             unset($artefactid);
         }
     }
     $otherblocksmsg = '<span id="textbox_blockcount">' . $otherblockcount . '</span>';
     $otherblocksmsg = get_string('textusedinotherblocks', 'blocktype.internal/textbox', $otherblocksmsg);
     $manageurl = get_config('wwwroot') . 'artefact/internal/notes.php';
     if ($group = $view->get('group')) {
         $manageurl .= '?group=' . $group;
     } else {
         if ($institution = $view->get('institution')) {
             $manageurl .= '?institution=' . $institution;
         }
     }
     // Update the attached files in block configdata as
     // it may change when attached files have been deleted
     $attachmentids = isset($artefact) ? $artefact->attachment_id_list() : false;
     if ($attachmentids !== false && $configdata['artefactids'] != $attachmentids) {
         $configdata['artefactids'] = $attachmentids;
         $instance->set('configdata', $configdata);
         $instance->commit();
     }
     $elements = array('otherblocksmsg' => array('type' => 'html', 'class' => 'message info' . ($otherblockcount && !$readonly ? '' : ' hidden'), 'value' => $otherblocksmsg, 'help' => true), 'readonlymsg' => array('type' => 'html', 'class' => 'message info' . ($readonly ? '' : ' hidden'), 'value' => get_string('readonlymessage', 'blocktype.internal/textbox'), 'help' => true), 'text' => array('type' => 'wysiwyg', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('note', 'blocktype.internal/eselmagraduation'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $text, 'rules' => array('maxlength' => 65536)), 'textreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('note', 'blocktype.internal/eselmagraduation'), 'width' => '100%', 'value' => '<div id="instconf_textreadonly_display">' . $text . '</div>'), 'makecopy' => array('type' => 'checkbox', 'class' => 'hidden', 'defaultvalue' => false), 'chooseartefact' => array('type' => 'html', 'class' => 'nojs-hidden-block', 'value' => '<a id="chooseartefactlink" href=""></a>'), 'managenotes' => array('type' => 'html', 'class' => 'right hidden', 'value' => '<a href="' . $manageurl . '" target="_blank">' . get_string('managealltextboxcontent1', 'blocktype.internal/textbox') . ' &raquo;</a>'), 'selecttask' => array('type' => 'select', 'title' => get_string('selecttask', 'view'), 'description' => get_string('selecttaskdescription', 'view'), 'options' => PluginBlocktypeEselmagraduation::get_task(), 'defaultvalue' => $retractable + $retractedonload), 'artefactid' => self::artefactchooser_element(isset($artefactid) ? $artefactid : null), 'literature' => array('type' => 'text', 'title' => get_string('literature'), 'defaultvalue' => $literature), 'information' => array('type' => 'wysiwyg', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('information', 'blocktype.internal/eselmagraduation'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $information, 'rules' => array('maxlength' => 65536)), 'allowcomments' => array('type' => 'switchbox', 'title' => get_string('allowcomments', 'artefact.comment'), 'defaultvalue' => !empty($artefact) ? $artefact->get('allowcomments') : 1), 'artefactids' => self::filebrowser_element($instance, isset($configdata['artefactids']) ? $configdata['artefactids'] : null));
     return $elements;
 }
开发者ID:vohung96,项目名称:mahara,代码行数:52,代码来源:lib.php

示例14: install_system_profile_view

/**
 * This function installs the site's default profile view
 *
 * @throws SystemException if the system profile view is already installed
 */
function install_system_profile_view()
{
    $viewid = get_field('view', 'id', 'owner', 0, 'type', 'profile');
    if ($viewid) {
        throw new SystemException('A system profile view already seems to be installed');
    }
    require_once get_config('libroot') . 'view.php';
    require_once get_config('docroot') . 'blocktype/lib.php';
    $view = View::create(array('type' => 'profile', 'owner' => 0, 'numcolumns' => 2, 'ownerformat' => FORMAT_NAME_PREFERREDNAME, 'title' => get_string('profileviewtitle', 'view'), 'description' => '', 'template' => 1));
    $view->set_access(array(array('type' => 'loggedin')));
    $blocktypes = array('myviews' => 1, 'mygroups' => 1, 'myfriends' => 2, 'wall' => 2);
    // column ids
    $installed = get_column_sql('SELECT name FROM {blocktype_installed} WHERE name IN (' . join(',', array_map('db_quote', array_keys($blocktypes))) . ')');
    $weights = array(1 => 0, 2 => 0);
    foreach (array_keys($blocktypes) as $blocktype) {
        if (in_array($blocktype, $installed)) {
            $weights[$blocktypes[$blocktype]]++;
            $newblock = new BlockInstance(0, array('blocktype' => $blocktype, 'title' => get_string('title', 'blocktype.' . $blocktype), 'view' => $view->get('id'), 'column' => $blocktypes[$blocktype], 'order' => $weights[$blocktypes[$blocktype]]));
            $newblock->commit();
        }
    }
    return $view->get('id');
}
开发者ID:Br3nda,项目名称:mahara,代码行数:28,代码来源:user.php


注:本文中的BlockInstance::commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。