예제 #1
0
 public function __construct($data)
 {
     if (empty($data)) {
         $data = array();
     }
     foreach ((array) $data as $field => $value) {
         if (property_exists($this, $field)) {
             $this->{$field} = $value;
         }
     }
     $this->blocktype = 'image';
     $this->artefactplugin = blocktype_artefactplugin($this->blocktype);
 }
예제 #2
0
파일: mahara.php 프로젝트: kienv/mahara
/**
 * Given a blocktype name, convert it to the namespaced version.
 *
 * This will be $artefacttype/$blocktype, or just plain $blocktype for system
 * blocktypes.
 *
 * This is useful for language strings
 */
function blocktype_name_to_namespaced($blocktype)
{
    static $resultcache = array();
    if (!isset($resultcache[$blocktype])) {
        $artefactplugin = blocktype_artefactplugin($blocktype);
        if ($artefactplugin) {
            $resultcache[$blocktype] = "{$artefactplugin}/{$blocktype}";
        } else {
            $resultcache[$blocktype] = $blocktype;
        }
    }
    return $resultcache[$blocktype];
}
예제 #3
0
파일: lib.php 프로젝트: sarahjcotton/mahara
 public function __construct($id = 0, $data = null)
 {
     if (!empty($id)) {
         if (empty($data)) {
             if (!($data = get_record('block_instance', 'id', $id))) {
                 // TODO: 1) doesn't need get string here if this is the
                 // only place the exception is used - can be done in the
                 // class itself. 2) String needs to be defined, or taken
                 // from lang/*/view.php where there is already one for it
                 throw new BlockInstanceNotFoundException(get_string('blockinstancenotfound', 'error', $id));
             }
         }
         $this->id = $id;
     } else {
         $this->dirty = true;
     }
     if (empty($data)) {
         $data = array();
     }
     foreach ((array) $data as $field => $value) {
         if (property_exists($this, $field)) {
             $this->{$field} = $value;
         }
     }
     $this->artefactplugin = blocktype_artefactplugin($this->blocktype);
 }