コード例 #1
0
    /**
     * Parse the array of lines into an array of questions
     * this *could* burn memory - but it won't happen that much
     * so fingers crossed!
     * @param array of lines from the input file.
     * @param stdClass $context
     * @return array (of objects) question objects.
     */
    protected function readquestions($lines) {

        $text = implode($lines, ' ');
        unset($lines);

        // This converts xml to big nasty data structure,
        // the 0 means keep white space as it is.
        try {
            $xml = xmlize($text, 0, 'UTF-8', true);
        } catch (xml_format_exception $e) {
            $this->error($e->getMessage(), '');
            return false;
        }

        $questions = array();

        $this->process_tf($xml, $questions);
        $this->process_mc($xml, $questions);
        $this->process_ma($xml, $questions);
        $this->process_fib($xml, $questions);
        $this->process_matching($xml, $questions);
        $this->process_essay($xml, $questions);

        return $questions;
    }
コード例 #2
0
 /**
  * import
  *
  * @param string $xml
  * @param object $block_instance
  * @param object $course
  * @return boolean true if import was successful, false otherwise
  */
 public function import($xml, $block_instance, $course)
 {
     global $DB;
     if (!($xml = xmlize($xml, 0))) {
         return false;
     }
     // set main XML tag name for this block's config settings
     $BLOCK = strtoupper($block_instance->blockname);
     $BLOCK = strtr($BLOCK, array('_' => '')) . 'BLOCK';
     if (!isset($xml[$BLOCK]['#']['CONFIGFIELDS'][0]['#']['CONFIGFIELD'])) {
         return false;
     }
     $configfield =& $xml[$BLOCK]['#']['CONFIGFIELDS'][0]['#']['CONFIGFIELD'];
     $config = unserialize(base64_decode($block_instance->configdata));
     if (empty($config)) {
         $config = new stdClass();
     }
     $i = 0;
     while (isset($configfield[$i]['#'])) {
         $name = $configfield[$i]['#']['NAME'][0]['#'];
         $value = $configfield[$i]['#']['VALUE'][0]['#'];
         $config->{$name} = $value;
         $i++;
     }
     if ($i == 0) {
         return false;
     }
     $block_instance->configdata = base64_encode(serialize($config));
     $DB->set_field('block_instances', 'configdata', $block_instance->configdata, array('id' => $block_instance->id));
     return true;
 }
コード例 #3
0
ファイル: formatqti.php プロジェクト: rwijaya/moodle
    /**
     * Parse the xml document into an array of questions
     * this *could* burn memory - but it won't happen that much
     * so fingers crossed!
     * @param array of lines from the input file.
     * @param stdClass $context
     * @return array (of objects) questions objects.
     */
    protected function readquestions($text) {

        // This converts xml to big nasty data structure,
        // the 0 means keep white space as it is.
        try {
            $xml = xmlize($text, 0, 'UTF-8', true);
        } catch (xml_format_exception $e) {
            $this->error($e->getMessage(), '');
            return false;
        }

        $questions = array();

        // Treat the assessment title as a category title.
        $this->process_category($xml, $questions);

        // First step : we are only interested in the <item> tags.
        $rawquestions = $this->getpath($xml,
                array('questestinterop', '#', 'assessment', 0, '#', 'section', 0, '#', 'item'),
                array(), false);
        // Each <item> tag contains data related to a single question.
        foreach ($rawquestions as $quest) {
            // Second step : parse each question data into the intermediate
            // rawquestion structure array.
            // Warning : rawquestions are not Moodle questions.
            $question = $this->create_raw_question($quest);
            // Third step : convert a rawquestion into a Moodle question.
            switch($question->qtype) {
                case "Matching":
                    $this->process_matching($question, $questions);
                    break;
                case "Multiple Choice":
                    $this->process_mc($question, $questions);
                    break;
                case "Essay":
                    $this->process_essay($question, $questions);
                    break;
                case "Multiple Answer":
                    $this->process_ma($question, $questions);
                    break;
                case "True/False":
                    $this->process_tf($question, $questions);
                    break;
                case 'Fill in the Blank':
                    $this->process_fblank($question, $questions);
                    break;
                case 'Short Response':
                    $this->process_essay($question, $questions);
                    break;
                default:
                    $this->error(get_string('unknownorunhandledtype', 'question', $question->qtype));
                    break;
            }
        }
        return $questions;
    }
コード例 #4
0
ファイル: class.rss.php プロジェクト: alencarmo/OCF
 function rss($a)
 {
     // $a deve ser o caminho para o rss
     // Primeiro armazenamos o xml
     $data = file_get_contents($a);
     $info = xmlize($data, 1, 'ISO-8859-1');
     $this->title = $info["rss"]["#"]["channel"][0]["#"]["title"][0]["#"];
     // Titulo do RSS
     $this->link = $info["rss"]["#"]["channel"][0]["#"]["link"][0]["#"];
     // Link para a pagina
     $this->itens = $info["rss"]["#"]["channel"][0]["#"]["item"];
     // Conteudo do RSS
 }
コード例 #5
0
ファイル: format.php プロジェクト: veritech/pare-project
 function readquestions($lines)
 {
     /// Parses an array of lines into an array of questions,
     /// where each item is a question object as defined by
     /// readquestion().
     $text = implode($lines, " ");
     $xml = xmlize($text, 0);
     $questions = array();
     $this->process_tf($xml, $questions);
     $this->process_mc($xml, $questions);
     $this->process_ma($xml, $questions);
     $this->process_fib($xml, $questions);
     $this->process_matching($xml, $questions);
     return $questions;
 }
コード例 #6
0
    function validation($data, $files) {
        $errors = array();

        if($file = $this->get_draft_files('importfile')){
            $file = reset($file);
            $content = $file->get_content();
            $xml = xmlize($content);
            if(empty($content)){
                $errors['importfile'] = get_string('error_emptyfile', 'report_rolesmigration');
            }else if(!$xml || !roles_migration_get_incoming_roles($xml)){
                $errors['importfile'] = get_string('error_badxml', 'report_rolesmigration');
            }
        }

        return $errors;
    }
コード例 #7
0
ファイル: XMLDBFile.class.php プロジェクト: Br3nda/mahara
 /**
  * Load and the XMLDB structure from file
  */
 function loadXMLStructure()
 {
     if ($this->fileExists()) {
         /// File exists, so let's process it
         /// Load everything to a big array
         $contents = file_get_contents($this->path);
         if (function_exists('local_xmldb_contents_sub')) {
             local_xmldb_contents_sub($contents);
         }
         $xmlarr = xmlize($contents);
         /// Convert array to xmldb structure
         $this->xmldb_structure = $this->arr2XMLDBStructure($xmlarr);
         /// Analize results
         if ($this->xmldb_structure->isLoaded()) {
             $this->loaded = true;
             return true;
         } else {
             return false;
         }
     }
     return true;
 }
コード例 #8
0
ファイル: lib.php プロジェクト: nottmoo/moodle
    /**
     * Gets the preset settings
     * @global moodle_database $DB
     * @return stdClass
     */
    public function get_preset_settings() {
        global $DB;

        $fs = $fileobj = null;
        if (!is_directory_a_preset($this->directory)) {
            //maybe the user requested a preset stored in the Moodle file storage

            $fs = get_file_storage();
            $files = $fs->get_area_files(DATA_PRESET_CONTEXT, DATA_PRESET_COMPONENT, DATA_PRESET_FILEAREA);

            //preset name to find will be the final element of the directory
            $presettofind = end(explode('/',$this->directory));

            //now go through the available files available and see if we can find it
            foreach ($files as $file) {
                if (($file->is_directory() && $file->get_filepath()=='/') || !$file->is_directory()) {
                    continue;
                }
                $presetname = trim($file->get_filepath(), '/');
                if ($presetname==$presettofind) {
                    $this->directory = $presetname;
                    $fileobj = $file;
                }
            }

            if (empty($fileobj)) {
                print_error('invalidpreset', 'data', '', $this->directory);
            }
        }

        $allowed_settings = array(
            'intro',
            'comments',
            'requiredentries',
            'requiredentriestoview',
            'maxentries',
            'rssarticles',
            'approval',
            'defaultsortdir',
            'defaultsort');

        $result = new stdClass;
        $result->settings = new stdClass;
        $result->importfields = array();
        $result->currentfields = $DB->get_records('data_fields', array('dataid'=>$this->module->id));
        if (!$result->currentfields) {
            $result->currentfields = array();
        }


        /* Grab XML */
        $presetxml = $this->data_preset_get_file_contents($fs, $fileobj, $this->directory,'preset.xml');
        $parsedxml = xmlize($presetxml, 0);

        /* First, do settings. Put in user friendly array. */
        $settingsarray = $parsedxml['preset']['#']['settings'][0]['#'];
        $result->settings = new StdClass();
        foreach ($settingsarray as $setting => $value) {
            if (!is_array($value) || !in_array($setting, $allowed_settings)) {
                // unsupported setting
                continue;
            }
            $result->settings->$setting = $value[0]['#'];
        }

        /* Now work out fields to user friendly array */
        $fieldsarray = $parsedxml['preset']['#']['field'];
        foreach ($fieldsarray as $field) {
            if (!is_array($field)) {
                continue;
            }
            $f = new StdClass();
            foreach ($field['#'] as $param => $value) {
                if (!is_array($value)) {
                    continue;
                }
                $f->$param = $value[0]['#'];
            }
            $f->dataid = $this->module->id;
            $f->type = clean_param($f->type, PARAM_ALPHA);
            $result->importfields[] = $f;
        }
        /* Now add the HTML templates to the settings array so we can update d */
        $result->settings->singletemplate     = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"singletemplate.html");
        $result->settings->listtemplate       = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"listtemplate.html");
        $result->settings->listtemplateheader = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"listtemplateheader.html");
        $result->settings->listtemplatefooter = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"listtemplatefooter.html");
        $result->settings->addtemplate        = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"addtemplate.html");
        $result->settings->rsstemplate        = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"rsstemplate.html");
        $result->settings->rsstitletemplate   = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"rsstitletemplate.html");
        $result->settings->csstemplate        = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"csstemplate.css");
        $result->settings->jstemplate         = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"jstemplate.js");

        //optional
        if (file_exists($this->directory."/asearchtemplate.html")) {
            $result->settings->asearchtemplate = $this->data_preset_get_file_contents($fs, $fileobj,$this->directory,"asearchtemplate.html");
        } else {
            $result->settings->asearchtemplate = NULL;
        }
        $result->settings->instance = $this->module->id;

        return $result;
    }
コード例 #9
0
ファイル: format.php プロジェクト: saurabh947/MoodleLearning
 /**
  * Parse the array of lines into an array of questions
  * this *could* burn memory - but it won't happen that much
  * so fingers crossed!
  * @param array of lines from the input file.
  * @param stdClass $context
  * @return array (of objects) question objects.
  */
 protected function readquestions($lines)
 {
     // We just need it as one big string
     $lines = implode('', $lines);
     // This converts xml to big nasty data structure
     // the 0 means keep white space as it is (important for markdown format)
     try {
         $xml = xmlize($lines, 0, 'UTF-8', true);
     } catch (xml_format_exception $e) {
         $this->error($e->getMessage(), '');
         return false;
     }
     unset($lines);
     // No need to keep this in memory.
     // Set up array to hold all our questions
     $questions = array();
     // Iterate through questions
     foreach ($xml['quiz']['#']['question'] as $question) {
         $questiontype = $question['@']['type'];
         if ($questiontype == 'multichoice') {
             $qo = $this->import_multichoice($question);
         } else {
             if ($questiontype == 'truefalse') {
                 $qo = $this->import_truefalse($question);
             } else {
                 if ($questiontype == 'shortanswer') {
                     $qo = $this->import_shortanswer($question);
                 } else {
                     if ($questiontype == 'numerical') {
                         $qo = $this->import_numerical($question);
                     } else {
                         if ($questiontype == 'description') {
                             $qo = $this->import_description($question);
                         } else {
                             if ($questiontype == 'matching' || $questiontype == 'match') {
                                 $qo = $this->import_match($question);
                             } else {
                                 if ($questiontype == 'cloze' || $questiontype == 'multianswer') {
                                     $qo = $this->import_multianswer($question);
                                 } else {
                                     if ($questiontype == 'essay') {
                                         $qo = $this->import_essay($question);
                                     } else {
                                         if ($questiontype == 'calculated') {
                                             $qo = $this->import_calculated($question);
                                         } else {
                                             if ($questiontype == 'calculatedsimple') {
                                                 $qo = $this->import_calculated($question);
                                                 $qo->qtype = 'calculatedsimple';
                                             } else {
                                                 if ($questiontype == 'calculatedmulti') {
                                                     $qo = $this->import_calculated($question);
                                                     $qo->qtype = 'calculatedmulti';
                                                 } else {
                                                     if ($questiontype == 'category') {
                                                         $qo = $this->import_category($question);
                                                     } else {
                                                         // Not a type we handle ourselves. See if the question type wants
                                                         // to handle it.
                                                         if (!($qo = $this->try_importing_using_qtypes($question, null, null, $questiontype))) {
                                                             $this->error(get_string('xmltypeunsupported', 'qformat_xml', $questiontype));
                                                             $qo = null;
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // Stick the result in the $questions array
         if ($qo) {
             $questions[] = $qo;
         }
     }
     return $questions;
 }
コード例 #10
0
ファイル: restorelib.php プロジェクト: kai707/ITSA-backup
 function endElementLogs($parser, $tagName)
 {
     //Check if we are into LOGS zone
     if ($this->tree[3] == "LOGS") {
         //if (trim($this->content))                                                                     //Debug
         //    echo "C".str_repeat("&nbsp;",($this->level+2)*2).$this->getContents()."<br />\n";           //Debug
         //echo $this->level.str_repeat("&nbsp;",$this->level*2)."&lt;/".$tagName."&gt;<br />\n";          //Debug
         //Acumulate data to info (content + close tag)
         //Reconvert: strip htmlchars again and trim to generate xml data
         if (!isset($this->temp)) {
             $this->temp = "";
         }
         $this->temp .= htmlspecialchars(trim($this->content)) . "</" . $tagName . ">";
         //If we've finished a log, xmlize it an save to db
         if ($this->level == 4 and $tagName == "LOG") {
             //Prepend XML standard header to info gathered
             $xml_data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . $this->temp;
             //Call to xmlize for this portion of xml data (one LOG)
             //echo "-XMLIZE: ".strftime ("%X",time()),"-";                                                //Debug
             $data = xmlize($xml_data, 0);
             //echo strftime ("%X",time())."<p>";                                                          //Debug
             //traverse_xmlize($data);                                                                     //Debug
             //print_object ($GLOBALS['traverse_array']);                                                  //Debug
             //$GLOBALS['traverse_array']="";                                                              //Debug
             //Now, save data to db. We'll use it later
             //Get id and modtype from data
             $log_id = $data["LOG"]["#"]["ID"]["0"]["#"];
             $log_module = $data["LOG"]["#"]["MODULE"]["0"]["#"];
             //We only save log entries from backup file if they are:
             // - Course logs
             // - User logs
             // - Module logs about one restored module
             if ($log_module == "course" or $log_module == "user" or $this->preferences->mods[$log_module]->restore) {
                 //Increment counter
                 $this->counter++;
                 //Save to db
                 $status = backup_putid($this->preferences->backup_unique_code, "log", $log_id, null, $data);
                 //echo "<p>id: ".$mod_id."-".$mod_type." len.: ".strlen($sla_mod_temp)." to_db: ".$status."<p>";   //Debug
                 //Create returning info
                 $this->info = $this->counter;
             }
             //Reset temp
             unset($this->temp);
         }
     }
     //Stop parsing if todo = LOGS and tagName = LOGS (en of the tag, of course)
     //Speed up a lot (avoid parse all)
     if ($tagName == "LOGS" and $this->level == 3) {
         $this->finished = true;
         $this->counter = 0;
     }
     //Clear things
     $this->tree[$this->level] = "";
     $this->level--;
     $this->content = "";
 }
コード例 #11
0
ファイル: ping.php プロジェクト: ryivhnn/friendica
function ping_init(&$a)
{
    header("Content-type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n\t\t<result>";
    $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
    if (local_user()) {
        $tags = array();
        $comments = array();
        $likes = array();
        $dislikes = array();
        $friends = array();
        $posts = array();
        $cit = array();
        $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, \n\t\t\t\t`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`, `item`.`body`, \n\t\t\t\t`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink` \n\t\t\t\tFROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`\n\t\t\t\tWHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND\n\t\t\t\t `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 \n\t\t\t\tORDER BY `item`.`created` DESC", intval(local_user()));
        $network = count($r);
        foreach ($r as $it) {
            switch ($it['verb']) {
                case ACTIVITY_TAG:
                    $obj = parse_xml_string($xmlhead . $it['object']);
                    $it['tname'] = $obj->content;
                    $tags[] = $it;
                    break;
                case ACTIVITY_LIKE:
                    $likes[] = $it;
                    break;
                case ACTIVITY_DISLIKE:
                    $dislikes[] = $it;
                    break;
                case ACTIVITY_FRIEND:
                    $obj = parse_xml_string($xmlhead . $it['object']);
                    $it['fname'] = $obj->title;
                    $friends[] = $it;
                    break;
                default:
                    $reg = "|@\\[url=" . $a->get_baseurl() . "/profile/" . $a->user['nickname'] . "|";
                    if ($it['parent'] != $it['id']) {
                        $comments[] = $it;
                    } else {
                        if (preg_match($reg, $it['body'])) {
                            $cit[] = $it;
                        } else {
                            $posts[] = $it;
                        }
                    }
            }
        }
        $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, \n\t\t\t\t`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`, \n\t\t\t\t`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink` \n\t\t\t\tFROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`\n\t\t\t\tWHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND\n\t\t\t\t `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1", intval(local_user()));
        $home = count($r);
        foreach ($r as $it) {
            switch ($it['verb']) {
                case ACTIVITY_TAG:
                    $obj = parse_xml_string($xmlhead . $it['object']);
                    $it['tname'] = $obj->content;
                    $tags[] = $it;
                    break;
                case ACTIVITY_LIKE:
                    $likes[] = $it;
                    break;
                case ACTIVITY_DISLIKE:
                    $dislikes[] = $it;
                    break;
                case ACTIVITY_FRIEND:
                    $obj = parse_xml_string($xmlhead . $it['object']);
                    $it['fname'] = $obj->title;
                    $friends[] = $it;
                    break;
                default:
                    if ($it['parent'] != $it['id']) {
                        $comments[] = $it;
                    }
                    if (preg_match("/@\\[[^]]*\\]" . $a->user['username'] . "/", $it['body'])) {
                        $cit[] = $it;
                    }
            }
        }
        $intros1 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`, \n\t\t\t`fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo` \n\t\t\tFROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`\n\t\t\tWHERE `intro`.`uid` = %d  AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0", intval(local_user()));
        $intros2 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`, \n\t\t\t`contact`.`name`, `contact`.`url`, `contact`.`photo` \n\t\t\tFROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`\n\t\t\tWHERE `intro`.`uid` = %d  AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0", intval(local_user()));
        $intro = $intros1[0]['total'] + $intros2[0]['total'];
        if ($intros1[0]['total'] == 0) {
            $intros1 = array();
        }
        if ($intros2[0]['total'] == 0) {
            $intros2 = array();
        }
        $intros = $intros1 + $intros2;
        $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
        $mails = q("SELECT *,  COUNT(*) AS `total` FROM `mail`\n\t\t\tWHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ", intval(local_user()), dbesc($myurl));
        $mail = $mails[0]['total'];
        if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()) {
            $regs = q("SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`, COUNT(*) as `total` FROM `contact` RIGHT JOIN `register` ON `register`.`uid`=`contact`.`uid` WHERE `contact`.`self`=1");
            $register = $regs[0]['total'];
        } else {
            $register = "0";
        }
        function xmlize($href, $name, $url, $photo, $date, $message)
        {
            $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s">%s</note>';
            return sprintf($notsxml, xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($message));
        }
        echo "<intro>{$intro}</intro>\n\t\t\t\t<mail>{$mail}</mail>\n\t\t\t\t<net>{$network}</net>\n\t\t\t\t<home>{$home}</home>";
        if ($register != 0) {
            echo "<register>{$register}</register>";
        }
        $tot = $mail + $intro + $register + count($comments) + count($likes) + count($dislikes) + count($friends) + count($posts) + count($tags) + count($cit);
        echo '	<notif count="' . $tot . '">';
        if ($intro > 0) {
            foreach ($intros as $i) {
                echo xmlize($a->get_baseurl() . '/notifications/intros/' . $i['id'], $i['name'], $i['url'], $i['photo'], relative_date($i['datetime']), t("{0} wants to be your friend"));
            }
        }
        if ($mail > 0) {
            foreach ($mails as $i) {
                echo xmlize($a->get_baseurl() . '/message/' . $i['id'], $i['from-name'], $i['from-url'], $i['from-photo'], relative_date($i['created']), t("{0} sent you a message"));
            }
        }
        if ($register > 0) {
            foreach ($regs as $i) {
                echo xmlize($a->get_baseurl() . '/admin/users/', $i['name'], $i['url'], $i['micro'], relative_date($i['created']), t("{0} requested registration"));
            }
        }
        if (count($comments)) {
            foreach ($comments as $i) {
                echo xmlize($a->get_baseurl() . '/display/' . $a->user['nickname'] . "/" . $i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf(t("{0} commented %s's post"), $i['pname']));
            }
        }
        if (count($likes)) {
            foreach ($likes as $i) {
                echo xmlize($a->get_baseurl() . '/display/' . $a->user['nickname'] . "/" . $i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf(t("{0} liked %s's post"), $i['pname']));
            }
        }
        if (count($dislikes)) {
            foreach ($dislikes as $i) {
                echo xmlize($a->get_baseurl() . '/display/' . $a->user['nickname'] . "/" . $i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf(t("{0} disliked %s's post"), $i['pname']));
            }
        }
        if (count($friends)) {
            foreach ($friends as $i) {
                echo xmlize($a->get_baseurl() . '/display/' . $a->user['nickname'] . "/" . $i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf(t("{0} is now friends with %s"), $i['fname']));
            }
        }
        if (count($posts)) {
            foreach ($posts as $i) {
                echo xmlize($a->get_baseurl() . '/display/' . $a->user['nickname'] . "/" . $i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), t("{0} posted"));
            }
        }
        if (count($tags)) {
            foreach ($tags as $i) {
                echo xmlize($a->get_baseurl() . '/display/' . $a->user['nickname'] . "/" . $i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf(t("{0} tagged %s's post with #%s"), $i['pname'], $i['tname']));
            }
        }
        if (count($cit)) {
            foreach ($cit as $i) {
                echo xmlize($a->get_baseurl() . '/display/' . $a->user['nickname'] . "/" . $i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), t("{0} mentioned you in a post"));
            }
        }
        echo "  </notif>";
    }
    echo " <sysmsgs>";
    if (x($_SESSION, 'sysmsg')) {
        foreach ($_SESSION['sysmsg'] as $m) {
            echo "<notice>" . xmlify($m) . "</notice>";
        }
        unset($_SESSION['sysmsg']);
    }
    if (x($_SESSION, 'sysmsg_info')) {
        foreach ($_SESSION['sysmsg_info'] as $m) {
            echo "<info>" . xmlify($m) . "</info>";
        }
        unset($_SESSION['sysmsg_info']);
    }
    echo " </sysmsgs>";
    echo "</result>\n\t";
    killme();
}
コード例 #12
0
ファイル: test.php プロジェクト: haseok86/millkencode
<?php

//====================================================
//		FileName:	.php
//		Summary:	描述
//		Author:		millken(迷路林肯)
//		LastModifed:2007-08-10
//		copyright (c)2007 millken@gmail.com
//====================================================
include 'common.inc.php';
include ROOT_PATH . 'include/xmlize.inc.php';
$xmldata = file_get_contents(ROOT_PATH . 'cache/top500.xml');
$xml = xmlize($xmldata);
foreach ($xml['result']['#']['data'] as $x) {
    $temp = explode('$$', $x['#']['name']['0']['#']);
    $list_array[] = array('id' => $x['#']['id']['0']['#'], 'songname' => $temp[0], 'singer' => $temp[1]);
}
//print_r($list_array);
//$lines = file('temp.txt');
//foreach($lines as $l){
//	$newContent .= "		<Keyword>".trim($l)."</Keyword>\n";
//}
//file_put_contents('new.txt',$newContent);
function &a($a = '')
{
    echo func_num_args();
}
a();
print_r(ini_get_all());
コード例 #13
0
/**
 * This function will load the environment.xml file and xmlize it
 *
 * @global object
 * @staticvar mixed $data
 * @uses ENV_SELECT_NEWER
 * @uses ENV_SELECT_DATAROOT
 * @uses ENV_SELECT_RELEASE
 * @param int $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. Default ENV_SELECT_NEWER (BC)
 * @return mixed the xmlized structure or false on error
 */
function load_environment_xml($env_select = ENV_SELECT_NEWER)
{
    global $CFG;
    static $data;
    //Only load and xmlize once by request
    if (!empty($data)) {
        return $data;
    }
    /// First of all, take a look inside $CFG->dataroot/environment/environment.xml
    $file = $CFG->dataroot . '/environment/environment.xml';
    $internalfile = $CFG->dirroot . '/' . $CFG->admin . '/environment.xml';
    switch ($env_select) {
        case ENV_SELECT_NEWER:
            if (!is_file($file) || !is_readable($file) || filemtime($file) < filemtime($internalfile) || !($contents = file_get_contents($file))) {
                /// Fallback to fixed $CFG->admin/environment.xml
                if (!is_file($internalfile) || !is_readable($internalfile) || !($contents = file_get_contents($internalfile))) {
                    return false;
                }
            }
            break;
        case ENV_SELECT_DATAROOT:
            if (!is_file($file) || !is_readable($file) || !($contents = file_get_contents($file))) {
                return false;
            }
            break;
        case ENV_SELECT_RELEASE:
            if (!is_file($internalfile) || !is_readable($internalfile) || !($contents = file_get_contents($internalfile))) {
                return false;
            }
            break;
    }
    /// XML the whole file
    $data = xmlize($contents);
    return $data;
}
コード例 #14
0
    protected function readquestions($lines, $context) {
        /// Parses an array of lines into an array of questions,
        /// where each item is a question object as defined by
        /// readquestion().

        $questions = array();
        $currentquestion = array();

        $text = implode($lines, ' ');
        $text = $this->cleanUnicode($text);

        $xml = xmlize($text, 0);
        if (!empty($xml['examview']['#']['matching-group'])) {
            $this->parse_matching_groups($xml['examview']['#']['matching-group']);
        }

        $questionNode = $xml['examview']['#']['question'];
        foreach($questionNode as $currentquestion) {
            if ($question = $this->readquestion($currentquestion)) {
                $questions[] = $question;
            }
        }

        $this->process_matches($questions);
        return $questions;
    }
コード例 #15
0
function import_xml_grades($text, $course, &$error)
{
    global $USER;
    $importcode = get_new_importcode();
    $status = true;
    $content = xmlize($text);
    if (!empty($content['results']['#']['result'])) {
        $results = $content['results']['#']['result'];
        foreach ($results as $i => $result) {
            $gradeidnumber = $result['#']['assignment'][0]['#'];
            if (!($grade_items = grade_item::fetch_all(array('idnumber' => $gradeidnumber, 'courseid' => $course->id)))) {
                // gradeitem does not exist
                // no data in temp table so far, abort
                $status = false;
                $error = get_string('errincorrectgradeidnumber', 'gradeimport_xml', $gradeidnumber);
                break;
            } else {
                if (count($grade_items) != 1) {
                    $status = false;
                    $error = get_string('errduplicategradeidnumber', 'gradeimport_xml', $gradeidnumber);
                    break;
                } else {
                    $grade_item = reset($grade_items);
                }
            }
            // grade item locked, abort
            if ($grade_item->is_locked()) {
                $status = false;
                $error = get_string('gradeitemlocked', 'grades');
                break;
            }
            // check if user exist and convert idnumber to user id
            $useridnumber = $result['#']['student'][0]['#'];
            if (!($user = get_record('user', 'idnumber', addslashes($useridnumber)))) {
                // no user found, abort
                $status = false;
                $error = get_string('errincorrectuseridnumber', 'gradeimport_xml', $useridnumber);
                break;
            }
            // check if grade_grade is locked and if so, abort
            if ($grade_grade = new grade_grade(array('itemid' => $grade_item->id, 'userid' => $user->id))) {
                $grade_grade->grade_item =& $grade_item;
                if ($grade_grade->is_locked()) {
                    // individual grade locked, abort
                    $status = false;
                    $error = get_string('gradegradeslocked', 'grades');
                    break;
                }
            }
            $newgrade = new object();
            $newgrade->itemid = $grade_item->id;
            $newgrade->userid = $user->id;
            $newgrade->importcode = $importcode;
            $newgrade->importer = $USER->id;
            // check grade value exists and is a numeric grade
            if (isset($result['#']['score'][0]['#'])) {
                if (is_numeric($result['#']['score'][0]['#'])) {
                    $newgrade->finalgrade = $result['#']['score'][0]['#'];
                } else {
                    $status = false;
                    $error = get_string('badgrade', 'grades');
                    break;
                }
            } else {
                $newgrade->finalgrade = NULL;
            }
            // check grade feedback exists
            if (isset($result['#']['feedback'][0]['#'])) {
                $newgrade->feedback = $result['#']['feedback'][0]['#'];
            } else {
                $newgrade->feedback = NULL;
            }
            // insert this grade into a temp table
            if (!insert_record('grade_import_values', addslashes_recursive($newgrade))) {
                $status = false;
                // could not insert into temp table
                $error = get_string('importfailed', 'grades');
                break;
            }
        }
    } else {
        // no results section found in xml,
        // assuming bad format, abort import
        $status = false;
        $error = get_string('errbadxmlformat', 'gradeimport_xml');
    }
    if ($status) {
        return $importcode;
    } else {
        import_cleanup($importcode);
        return false;
    }
}
コード例 #16
0
ファイル: import.php プロジェクト: ajv/Offline-Caching
function feedback_load_xml_data($filename)
{
    global $CFG;
    require_once $CFG->dirroot . '/lib/xmlize.php';
    $datei = file_get_contents($filename);
    if (!($datei = feedback_check_xml_utf8($datei))) {
        return false;
    }
    $data = xmlize($datei, 1, 'UTF-8');
    if (intval($data['FEEDBACK']['@']['VERSION']) != 200701) {
        return false;
    }
    $data = $data['FEEDBACK']['#']['ITEMS'][0]['#']['ITEM'];
    return $data;
}
コード例 #17
0
ファイル: xmlformat_test.php プロジェクト: Jtgadbois/Pedadida
    public function test_import_files_as_draft() {
        $this->resetAfterTest();
        $this->setAdminUser();

        $xml = <<<END
<questiontext format="html">
    <text><![CDATA[<p><a href="@@PLUGINFILE@@/moodle.txt">This text file</a> contains the word 'Moodle'.</p>]]></text>
    <file name="moodle.txt" encoding="base64">TW9vZGxl</file>
</questiontext>
END;

        $textxml = xmlize($xml);
        $qo = new stdClass();

        $importer = new qformat_xml();
        $draftitemid = $importer->import_files_as_draft($textxml['questiontext']['#']['file']);
        $files = file_get_drafarea_files($draftitemid);

        $this->assertEquals(1, count($files->list));

        $file = $files->list[0];
        $this->assertEquals('moodle.txt', $file->filename);
        $this->assertEquals('/',          $file->filepath);
        $this->assertEquals(6,            $file->size);
    }
コード例 #18
0
ファイル: testxmlformat.php プロジェクト: robadobdob/moodle
    public function test_import_multianswer() {
        $xml = '  <question type="cloze">
    <name>
      <text>Simple multianswer</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[Complete this opening line of verse: "The {1:SHORTANSWER:Dog#Wrong, silly!~=Owl#Well done!~*#Wrong answer} and the {1:MULTICHOICE:Bow-wow#You seem to have a dog obsessions!~Wiggly worm#Now you are just being ridiculous!~=Pussy-cat#Well done!} went to sea".]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[General feedback: It\'s from "The Owl and the Pussy-cat" by Lear: "The owl and the pussycat went to sea".]]></text>
    </generalfeedback>
    <penalty>0.5</penalty>
    <hidden>0</hidden>
    <hint format="html">
      <text>Hint 1</text>
    </hint>
    <hint format="html">
      <text>Hint 2</text>
    </hint>
  </question>
';
        $xmldata = xmlize($xml);

        $importer = new qformat_xml();
        $q = $importer->import_multianswer($xmldata['question']);

        // Annoyingly, import works in a weird way (it duplicates code, rather
        // than just calling save_question) so we cannot use
        // test_question_maker::get_question_form_data('multianswer', 'twosubq').
        $expectedqa = new stdClass();
        $expectedqa->name = 'Simple multianswer';
        $expectedqa->qtype = 'multianswer';
        $expectedqa->questiontext = 'Complete this opening line of verse: "The {#1} and the {#2} went to sea".';
        $expectedqa->generalfeedback = 'General feedback: It\'s from "The Owl and the Pussy-cat" by Lear: "The owl and the pussycat went to sea".';
        $expectedqa->defaultmark = 2;
        $expectedqa->penalty = 0.5;

        $expectedqa->hint = array(
            array('text' => 'Hint 1', 'format' => FORMAT_HTML, 'files' => array()),
            array('text' => 'Hint 2', 'format' => FORMAT_HTML, 'files' => array()),
        );

        $sa = new stdClass();

        $sa->questiontext = array('text' => '{1:SHORTANSWER:Dog#Wrong, silly!~=Owl#Well done!~*#Wrong answer}',
                'format' => FORMAT_HTML, 'itemid' => null);
        $sa->generalfeedback = array('text' => '', 'format' => FORMAT_HTML, 'itemid' => null);
        $sa->defaultmark = 1.0;
        $sa->qtype = 'shortanswer';
        $sa->usecase = 0;

        $sa->answer = array('Dog', 'Owl', '*');
        $sa->fraction = array(0, 1, 0);
        $sa->feedback = array(
            array('text' => 'Wrong, silly!', 'format' => FORMAT_HTML, 'itemid' => null),
            array('text' => 'Well done!',    'format' => FORMAT_HTML, 'itemid' => null),
            array('text' => 'Wrong answer',  'format' => FORMAT_HTML, 'itemid' => null),
        );

        $mc = new stdClass();

        $mc->generalfeedback = '';
        $mc->questiontext = array('text' => '{1:MULTICHOICE:Bow-wow#You seem to have a dog obsessions!~' .
                'Wiggly worm#Now you are just being ridiculous!~=Pussy-cat#Well done!}',
                'format' => FORMAT_HTML, 'itemid' => null);
        $mc->generalfeedback = array('text' => '', 'format' => FORMAT_HTML, 'itemid' => null);
        $mc->defaultmark = 1.0;
        $mc->qtype = 'multichoice';

        $mc->layout = 0;
        $mc->single = 1;
        $mc->shuffleanswers = 1;
        $mc->correctfeedback =          array('text' => '', 'format' => FORMAT_HTML, 'itemid' => null);
        $mc->partiallycorrectfeedback = array('text' => '', 'format' => FORMAT_HTML, 'itemid' => null);
        $mc->incorrectfeedback =        array('text' => '', 'format' => FORMAT_HTML, 'itemid' => null);
        $mc->answernumbering = 0;

        $mc->answer = array(
            array('text' => 'Bow-wow',     'format' => FORMAT_HTML, 'itemid' => null),
            array('text' => 'Wiggly worm', 'format' => FORMAT_HTML, 'itemid' => null),
            array('text' => 'Pussy-cat',   'format' => FORMAT_HTML, 'itemid' => null),
        );
        $mc->fraction = array(0, 0, 1);
        $mc->feedback = array(
            array('text' => 'You seem to have a dog obsessions!', 'format' => FORMAT_HTML, 'itemid' => null),
            array('text' => 'Now you are just being ridiculous!', 'format' => FORMAT_HTML, 'itemid' => null),
            array('text' => 'Well done!',                         'format' => FORMAT_HTML, 'itemid' => null),
        );

        $expectedqa->options = new stdClass();
        $expectedqa->options->questions = array(
            1 => $sa,
            2 => $mc,
        );

        $this->assertEqual($expectedqa->hint, $q->hint);
        $this->assertEqual($expectedqa->options->questions[1], $q->options->questions[1]);
        $this->assertEqual($expectedqa->options->questions[2], $q->options->questions[2]);
        $this->assert(new CheckSpecifiedFieldsExpectation($expectedqa), $q);
    }
コード例 #19
0
 public function test_parse_matching_groups()
 {
     $lines = $this->make_test_xml();
     $importer = new qformat_examview();
     $text = implode($lines, ' ');
     $xml = xmlize($text, 0);
     $importer->parse_matching_groups($xml['examview']['#']['matching-group']);
     $matching = $importer->matching_questions;
     $group = new stdClass();
     $group->questiontext = 'Classify the animals.';
     $group->subchoices = array('A' => 'insect', 'B' => 'amphibian', 'C' => 'mammal');
     $group->subquestions = array();
     $group->subanswers = array();
     $expectedmatching = array('Matching 1' => $group);
     $this->assertEquals($matching, $expectedmatching);
 }
コード例 #20
0
ファイル: format.php プロジェクト: kai707/ITSA-backup
 function readquestions($lines)
 {
     /// Parses an array of lines into an array of questions,
     /// where each item is a question object as defined by
     /// readquestion().
     $text = implode($lines, " ");
     $xml = xmlize($text, 0);
     $raw_questions = $xml['questestinterop']['#']['assessment'][0]['#']['section'][0]['#']['item'];
     $questions = array();
     foreach ($raw_questions as $quest) {
         $question = $this->create_raw_question($quest);
         switch ($question->qtype) {
             case "Matching":
                 $this->process_matching($question, $questions);
                 break;
             case "Multiple Choice":
                 $this->process_mc($question, $questions);
                 break;
             case "Essay":
                 $this->process_essay($question, $questions);
                 break;
             case "Multiple Answer":
                 $this->process_ma($question, $questions);
                 break;
             case "True/False":
                 $this->process_tf($question, $questions);
                 break;
             case 'Fill in the Blank':
                 $this->process_fblank($question, $questions);
                 break;
             case 'Short Response':
                 $this->process_essay($question, $questions);
                 break;
             default:
                 print "Unknown or unhandled question type: \"{$question->qtype}\"<br />";
                 break;
         }
     }
     return $questions;
 }
コード例 #21
0
             $xmlcontentfnewtext .= "<QUESTION_CATEGORY>" . $xmlcontentfnew_;
         } else {
             $xmlcontentfnewtext .= $xmlcontentfnew_;
         }
         $c++;
     }
 }
 $xml_file = $CFG->dataroot . $dirq . '/moodle.xml';
 $restoreq->file = $CFG->dataroot . $dirq . '/moodle.zip';
 $fp = fopen($xml_file, "w+");
 fwrite($fp, $xmlcontentfnewtext);
 if (!($statusbackup = backup_zip($restoreq))) {
     print_error('Can\'t create backup zip file.');
 }
 $filelist = list_directories_and_files($CFG->dataroot . $dirq);
 $xmlarray = xmlize($xmlcontentfnewtext);
 //---------------Check images ----------------//
 $checkimagesarr = $xmlarray['MOODLE_BACKUP']['#']['COURSE']['0']['#']['QUESTION_CATEGORIES']['0']['#']['QUESTION_CATEGORY'];
 while (list($key, $value) = each($checkimagesarr)) {
     if (@is_array($value['#']['QUESTIONS']['0']['#']['QUESTION'])) {
         $dataquestarr = $value['#']['QUESTIONS']['0']['#']['QUESTION'];
         while (list($key2, $value2) = each($dataquestarr)) {
             if ($value2['#']['IMAGE']['0']['#']) {
                 //Upload Image-------//
                 $imglinks = explode("/", $value2['#']['IMAGE']['0']['#']);
                 end($imglinks);
                 unset($imglinks[key($imglinks)]);
                 $imglinks = implode("/", $imglinks);
                 make_upload_directory('reader/images');
                 $image = file_get_contents($readercfg->reader_serverlink . '/getfile_quiz_image.php?imagelink=' . urlencode($value2['#']['IMAGE']['0']['#']));
                 $fp = @fopen($CFG->dataroot . '/reader/images/' . $value2['#']['IMAGE']['0']['#'], "w+");
コード例 #22
0
ファイル: format.php プロジェクト: veritech/pare-project
 /**
  * parse the array of lines into an array of questions
  * this *could* burn memory - but it won't happen that much
  * so fingers crossed!
  * @param array lines array of lines from the input file
  * @return array (of objects) question objects
  */
 function readquestions($lines)
 {
     // we just need it as one big string
     $text = implode($lines, " ");
     unset($lines);
     // this converts xml to big nasty data structure
     // the 0 means keep white space as it is (important for markdown format)
     // print_r it if you want to see what it looks like!
     $xml = xmlize($text, 0);
     // set up array to hold all our questions
     $questions = array();
     // iterate through questions
     foreach ($xml['quiz']['#']['question'] as $question) {
         $question_type = $question['@']['type'];
         $questiontype = get_string('questiontype', 'quiz', $question_type);
         if ($question_type == 'multichoice') {
             $qo = $this->import_multichoice($question);
         } elseif ($question_type == 'truefalse') {
             $qo = $this->import_truefalse($question);
         } elseif ($question_type == 'shortanswer') {
             $qo = $this->import_shortanswer($question);
         } elseif ($question_type == 'numerical') {
             $qo = $this->import_numerical($question);
         } elseif ($question_type == 'description') {
             $qo = $this->import_description($question);
         } elseif ($question_type == 'matching') {
             $qo = $this->import_matching($question);
         } elseif ($question_type == 'cloze') {
             $qo = $this->import_multianswer($question);
         } elseif ($question_type == 'essay') {
             $qo = $this->import_essay($question);
         } elseif ($question_type == 'calculated') {
             $qo = $this->import_calculated($question);
         } elseif ($question_type == 'category') {
             $qo = $this->import_category($question);
         } else {
             // try for plugin support
             // no default question, as the plugin can call
             // import_headers() itself if it wants to
             if (!($qo = $this->try_importing_using_qtypes($question))) {
                 $notsupported = get_string('xmltypeunsupported', 'quiz', $question_type);
                 $this->error($notsupported);
                 $qo = null;
             }
         }
         // stick the result in the $questions array
         if ($qo) {
             $questions[] = $qo;
         }
     }
     return $questions;
 }
コード例 #23
0
ファイル: xmldb_file.php プロジェクト: evltuma/moodle
 /**
  * Load and the XMLDB structure from file
  * @return true
  */
 public function loadXMLStructure()
 {
     if ($this->fileExists()) {
         // Let's validate the XML file
         if (!$this->validateXMLStructure()) {
             return false;
         }
         $contents = file_get_contents($this->path);
         if (strpos($contents, '<STATEMENTS>')) {
             //delete the removed STATEMENTS section, it would not validate
             $contents = preg_replace('|<STATEMENTS>.*</STATEMENTS>|s', '', $contents);
             debugging('STATEMENTS section is not supported any more, please use db/install.php or db/log.php');
         }
         // File exists, so let's process it
         // Load everything to a big array
         $xmlarr = xmlize($contents);
         // Convert array to xmldb structure
         $this->xmldb_structure = $this->arr2xmldb_structure($xmlarr);
         // Analyze results
         if ($this->xmldb_structure->isLoaded()) {
             $this->loaded = true;
             return true;
         } else {
             return false;
         }
     }
     return true;
 }
コード例 #24
0
ファイル: deploy.php プロジェクト: nicolasconnault/moodle2.0
if (!($imsmanifest = ims_file2var($resourcedir . '/imsmanifest.xml'))) {
    print_error('errorreadingfile', 'error', '', 'imsmanifest.xml');
}
/// Check if the first line is a proper one, because I've seen some
/// packages with some control characters at the beginning.
$inixml = strpos($imsmanifest, '<?xml ');
if ($inixml !== false) {
    if ($inixml !== 0) {
        //Strip strange chars before "<?xml "
        $imsmanifest = substr($imsmanifest, $inixml);
    }
} else {
    print_error('invalidxmlfile', 'error', '', 'imsmanifest.xml');
}
/// xmlize the variable
$data = xmlize($imsmanifest, 0);
/// Extract every manifest present in the imsmanifest file.
/// Returns a tree structure.
if (!($manifests = ims_extract_manifests($data))) {
    print_error('nonmeaningfulcontent', 'error');
}
/// Process every manifest found in inverse order so every one
/// will be able to use its own submanifests. Not perfect because
/// teorically this will allow some manifests to use other non-childs
/// but this is supposed to be
/// Detect if all the manifest share a common xml:base tag
$manifest_base = $data['manifest']['@']['xml:base'];
/// Parse XML-metadata
/// Skip this for now (until a proper METADATA container was created in Moodle).
/// Parse XML-content package data
/// First we select an organization an load all the items
コード例 #25
0
 /**
  * Get the response from the last connection.
  *
  * @return string|bool    The response in XML form.
  */
 public function get_response_array()
 {
     return xmlize($this->response);
 }
コード例 #26
0
ファイル: lib.php プロジェクト: rolandovanegas/moodle
/**
 * Read import file and convert to current charset
 *
 * @global object
 * @param string $file
 * @return string
 */
function glossary_read_imported_file($file_content) {
    require_once "../../lib/xmlize.php";
    global $CFG;

    return xmlize($file_content, 0);
}
コード例 #27
0
function parseEPGDataXMLTVTVGuide($providerId)
{
    global $config, $programsXML, $system_timezone;
    $response = getEPGDataXMLTV($providerId);
    $start_time = strtotime($_GET['from_day']);
    $end_time = strtotime("+" . $_GET['DaysRequested'] . "days", $start_time);
    //$_GET['from_day']
    $programsXML = '';
    $programIds = array();
    $i = 1;
    foreach ($response->channel as $channel) {
        $source_id = (strpos($channel['id'], '.') !== FALSE ? '99' : '') . str_replace('.', '', $channel['id']);
        $programsXML .= '		<source>
			<source_ID>' . $source_id . '</source_ID>
			<guide>' . "\n";
        foreach ($response->programme as $program) {
            if ((string) $program['channel'] != (string) $channel['id']) {
                continue;
            }
            $start = (string) $program['start'];
            $end = (string) $program['stop'];
            $program_start_time = substr($start, 0, 4) . '-' . substr($start, 4, 2) . '-' . substr($start, 6, 2) . ' ' . substr($start, 8, 2) . ':' . substr($start, 10, 2);
            $program_start_time = strtotime("{$program_start_time} {$system_timezone}");
            if ($program_start_time < $start_time || $program_start_time >= $end_time) {
                continue;
            }
            unset($category);
            $runtime = startstopToRuntime($start, $end) * 60;
            if (!empty($program->category)) {
                $category = (string) $program->category[0];
            }
            $program->title = win2ascii($program->title);
            if (isset($program->{'sub-title'})) {
                $program->{'sub-title'} = win2ascii($program->{'sub-title'});
            }
            $hash = getProgramHash($program);
            if (!isset($programIds[$hash])) {
                $programIds[$hash] = $i++;
            }
            $programsXML .= '			<program>
				<start_date>' . date('Ymd', $program_start_time) . '</start_date>
				<start_time>' . date('Hi', $program_start_time) . '</start_time>
				<duration>' . $runtime . '</duration>
				<program_ID>' . $programIds[$hash] . '</program_ID>
				<tv_rating>None</tv_rating>
				<tv_advisory>None</tv_advisory>
				<program_showing_type>None</program_showing_type>
				<audio_level_name>' . (@$program->hd ? 'Dolby 5.1' : 'Stereo') . '</audio_level_name>
				<closed_captioned>Y</closed_captioned>
				<program_airing_type>None</program_airing_type>
				<program_color_type>Color</program_color_type>
				<joined_in_progress>N</joined_in_progress>
				<letter_box>N</letter_box>
				<black_white>N</black_white>
				<continued>N</continued>
				<hdtv_level>' . (@$program->hd ? '1080i' : 'None') . '</hdtv_level>
				<subtitled>N</subtitled>
				<genre>' . (@$category == 'Sports' ? 'sports' : (@$category == 'News' ? 'newscast' : getSerieGenre($program->title))) . '</genre>
				<show_type>' . (isProgramSeries($program) ? 'EP' : (@$category == 'Movies' ? 'MV' : (@$category == 'Sports' ? 'SP' : 'SM'))) . '</show_type>
				<grid_title>' . xmlize(substr($program->title, 0, 15)) . '</grid_title>
				<short_title>' . xmlize(substr($program->title, 0, 30)) . '</short_title>
				<short_grid_title>' . xmlize(substr($program->title, 0, 8)) . '</short_grid_title>
				<medium_title>' . xmlize(substr($program->title, 0, 50)) . '</medium_title>
				<long_title>' . xmlize($program->title) . '</long_title>
				' . (isset($program->{'sub-title'}) ? '<episode_title>' . xmlize($program->{'sub-title'}) . '</episode_title>' . "\n\t\t\t\t" : '') . '<half_stars_rating>0</half_stars_rating>
				<release_year>0</release_year>
				<mpaa_rating_reason />
				<audio_level>' . (@$program->hd ? 'Dolby 5.1' : 'Stereo') . '</audio_level>
			</program>' . "\n";
        }
        $programsXML .= '			</guide>
			</source>' . "\n";
    }
}
コード例 #28
0
ファイル: module.php プロジェクト: skullJ/ci-cms
 function install($module = null)
 {
     if (is_null($module)) {
         $this->session->set_flashdata('notification', __("Please select a module", $this->template['module']));
         redirect('admin/module');
     }
     if ($this->_is_installed($module)) {
         $this->session->set_flashdata('notification', __("The module you are trying to install is already installed", $this->template['module']));
         redirect('admin/module');
     }
     //now install it
     if (is_readable(APPPATH . 'modules/' . $module . '/setup.xml')) {
         $this->load->helper('xml');
         $xmldata = join('', file(APPPATH . 'modules/' . $module . '/setup.xml'));
         $xmlarray = xmlize($xmldata);
         if (isset($xmlarray['module']['#']['name'][0]['#']) && trim($xmlarray['module']['#']['name'][0]['#']) == $module) {
             $data['name'] = trim($xmlarray['module']['#']['name'][0]['#']);
             $data['description'] = isset($xmlarray['module']['#']['description'][0]['#']) ? trim($xmlarray['module']['#']['description'][0]['#']) : '';
             $data['version'] = isset($xmlarray['module']['#']['version'][0]['#']) ? trim($xmlarray['module']['#']['version'][0]['#']) : '';
             $data['status'] = 0;
             $data['ordering'] = 1000;
             $info['date'] = $xmlarray['module']['#']['date'][0]['#'];
             $info['author'] = $xmlarray['module']['#']['author'][0]['#'];
             $info['email'] = $xmlarray['module']['#']['email'][0]['#'];
             $info['url'] = $xmlarray['module']['#']['url'][0]['#'];
             $info['copyright'] = $xmlarray['module']['#']['copyright'][0]['#'];
             $data['info'] = serialize($info);
             if (file_exists(APPPATH . 'modules/' . $module . '/controllers/admin.php') || file_exists(APPPATH . 'modules/' . $module . '/controllers/admin/admin.php')) {
                 $data['with_admin'] = 1;
             }
             //execute queries
             if (isset($xmlarray['module']['#']['install'][0]['#']['query'])) {
                 $queries = $xmlarray['module']['#']['install'][0]['#']['query'];
                 foreach ($queries as $query) {
                     $this->db->query($query['#']);
                 }
             }
             if (is_file(APPPATH . 'modules/' . $module . '/' . $module . '_install.php')) {
                 @(include APPPATH . 'modules/' . $module . '/' . $module . '_install.php');
             }
             $this->session->set_flashdata('notification', __("The module is installed. Now you need to activate it.", $this->template['module']));
             $this->db->insert('modules', $data);
             $this->cache->remove('modulelist', 'system');
             redirect('admin/module');
         } else {
             $this->session->set_flashdata('notification', __("The module setup file is not valid.", $this->template['module']));
             redirect('admin/module');
         }
     } else {
         $this->session->set_flashdata('notification', __("Setup file not readable.", $this->template['module']));
         redirect('admin/module');
     }
 }
コード例 #29
0
ファイル: import.php プロジェクト: raymondAntonio/moodle
function feedback_load_xml_data($xmlcontent) {
    global $CFG;
    require_once($CFG->dirroot.'/lib/xmlize.php');

    if (!$xmlcontent = feedback_check_xml_utf8($xmlcontent)) {
        return false;
    }

    $data = xmlize($xmlcontent, 1, 'UTF-8');

    if (intval($data['FEEDBACK']['@']['VERSION']) != 200701) {
        return false;
    }
    $data = $data['FEEDBACK']['#']['ITEMS'][0]['#']['ITEM'];
    return $data;
}
コード例 #30
0
ファイル: upgrade.php プロジェクト: Br3nda/mahara
/**
 * Reload htmlpurifier filters from the XML configuration file.
 */
function reload_html_filters()
{
    require_once 'xmlize.php';
    log_info('Reading HTML filters');
    $newlist = xmlize(file_get_contents(get_config('libroot') . 'htmlpurifiercustom/filters.xml'));
    $filters = $newlist['filters']['#']['filter'];
    foreach ($filters as &$f) {
        $f = (object) array('site' => $f['#']['site'][0]['#'], 'file' => $f['#']['filename'][0]['#']);
        log_info('- ' . $f->file);
    }
    $filters[] = (object) array('site' => 'http://www.youtube.com', 'file' => 'YouTube');
    log_info('- YouTube');
    set_config('filters', serialize($filters));
}