Exemplo n.º 1
0
 public static function xml_unserialize(&$xml, $isnormal = FALSE)
 {
     $xml_parser = new Xml($isnormal);
     $data = $xml_parser->parse($xml);
     $xml_parser->destruct();
     return $data;
 }
Exemplo n.º 2
0
 public function __construct()
 {
     global $dbconfig;
     /*
      * ANTIGO METODO ANTES DO XML!!!
      * PEGAVA DIRETO DO CONFIGURATIONS.INC.PHP 
      * if(!isset(self::$conexao))
     {
     	$dsn = "{$dbconfig['driver']}:host={$dbconfig['server']};dbname={$dbconfig['database']}";
     }
     
     try
     {
     		self::$conexao = new PDO($dsn,	
     									 $dbconfig['user'],
     									 $dbconfig['password'],
     									 $dbconfig['options']);
     }
     */
     $xml = new Xml(_XML_DB_);
     $xml->setConstant();
     if (!isset(self::$conexao)) {
         $dsn = $xml->dsn();
         try {
             self::$conexao = new PDO($dsn, USER, PASSWORD);
         } catch (PDOException $e) {
             $erro = 'Erro: ' . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n";
             error_log(date('d-m-Y H:i:s') . '-' . $erro, 3, LOG_FILE);
             die($erro);
         }
     }
 }
 public function testParse()
 {
     $file = __DIR__ . '/_files/xmlPhrasesForTest.xml';
     $this->xmlPhraseCollector->parse($file);
     $expectation = [['phrase' => 'Name only', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'Name and title space delimiter', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'title1', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'title2', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'Name only in sub node', 'file' => $file, 'line' => '', 'quote' => ''], ['phrase' => 'Text outside of attribute', 'file' => $file, 'line' => '', 'quote' => '']];
     $this->assertEquals($expectation, $this->xmlPhraseCollector->getPhrases());
 }
Exemplo n.º 4
0
function plugin_dst_xml_read()
{
    // Perform the repository lookup and xml creation --- start
    $localFile = 'plugins/dst/countries.xml';
    $result = array('body' => file_get_contents($localFile));
    unset($result['headers']);
    // we should take a look the header data and error messages before dropping them. Well, later maybe ;-)
    unset($result['error']);
    $result = array_shift($result);
    if (function_exists('simplexml_load_string')) {
        $xml = simplexml_load_string($result);
        unset($result);
        $dst_array = array();
        foreach ($xml as $file) {
            $dst_array[] = (array) $file;
        }
    } else {
        include_once 'include/lib.xml.php';
        $xml = new Xml();
        $dst_array = $xml->parse($result);
        $dst_array = array_shift($dst_array);
    }
    // Perform the repository lookup and xml creation --- end
    return $dst_array;
}
Exemplo n.º 5
0
 /**
  * undocumented function
  *
  * @param string $file 
  * @return void
  * @access public
  */
 function import($file)
 {
     $source = file_get_contents($file);
     $xml = new Xml($source);
     $result = $xml->toArray();
     $result = $result['Xmlarchive']['Fileset']['File'];
     if (empty($result)) {
         return false;
     }
     $count = 0;
     foreach ($result as $smiley) {
         $name = $smiley['filename'];
         $content = $smiley['content'];
         $content = preg_replace('/\\s/', '', $content);
         $content = base64_decode($content);
         $filePath = SMILEY_PATH . $name;
         if (file_exists($filePath)) {
             continue;
         }
         $this->create(array('code' => ':' . r('.gif', '', $name) . ':', 'filename' => $name));
         $this->save();
         $f = fopen($filePath, 'w+');
         fwrite($f, $content);
         fclose($f);
         $count++;
     }
     return $count;
 }
Exemplo n.º 6
0
 public function get(&$accessToken, &$oauthConsumer)
 {
     // we need the GUID of the user for Yahoo
     $guid = $oauthConsumer->get($accessToken->key, $accessToken->secret, 'http://social.yahooapis.com/v1/me/guid');
     // Yahoo returns XML, so break it apart and make it an array
     $xml = new Xml($guid);
     // Or you can convert simply by calling toArray();
     $guid = $xml->toArray();
     // get them contacts
     $contacts = $oauthConsumer->get($accessToken->key, $accessToken->secret, 'http://social.yahooapis.com/v1/user/' . $guid['Guid']['value'] . '/contacts', array('count' => 'max', 'format' => 'xml'));
     // return array
     $c = array();
     // counter
     $i = 0;
     // new xml object
     $xml = new Xml($contacts);
     $contacts = $xml->toArray();
     // let's break apart Yahoo's contact format and make it our own, extracting what we want
     foreach ($contacts['Contacts']['Contact'] as $contact) {
         foreach ($contact['Fields'] as $field) {
             if ($field['type'] == 'email') {
                 $c[$i]['Contact']['email'][] = $field['value'];
             }
             if ($field['type'] == 'name' && isset($c[$i]['Contact']['email'])) {
                 $firstName = isset($field['Value']['givenName']) ? $field['Value']['givenName'] : '';
                 $lastName = isset($field['Value']['familyName']) ? $field['Value']['familyName'] : '';
                 $c[$i]['Contact']['fullName'] = $firstName . ' ' . $lastName;
             }
         }
         $i++;
     }
     return $c;
 }
 /**
  * Verifica se os menus do banco estão atualizados com os do arquivo
  * @param $aDados- array de menus do banco
  * @return boolean
  */
 public function isUpToDate($aDados)
 {
     $aDados = Set::combine($aDados, "/Menu/id", "/Menu");
     App::import("Xml");
     App::import("Folder");
     App::import("File");
     $sCaminhosArquivos = Configure::read("Cms.CheckPoint.menus");
     $oFolder = new Folder($sCaminhosArquivos);
     $aConteudo = $oFolder->read();
     $aArquivos = Set::sort($aConteudo[1], "{n}", "desc");
     if (empty($aArquivos)) {
         return false;
     }
     $oFile = new File($sCaminhosArquivos . $aArquivos[0]);
     $oXml = new Xml($oFile->read());
     $aAntigo = $oXml->toArray();
     foreach ($aDados as &$aMenu) {
         $aMenu['Menu']['content'] = str_replace("\r\n", " ", $aMenu['Menu']['content']);
     }
     if (isset($aAntigo["menus"])) {
         $aAntigo["Menus"] = $aAntigo["menus"];
         unset($aAntigo["menus"]);
     }
     if (isset($aAntigo["Menus"])) {
         $aAntigo = Set::combine($aAntigo["Menus"], "/Menu/id", "/Menu");
         $aRetorno = Set::diff($aDados, $aAntigo);
     }
     return empty($aRetorno);
 }
Exemplo n.º 8
0
 public function index()
 {
     $this->load->helper('directory');
     $map = directory_map(APPPATH . DS . 'modules', 1);
     // get all modules
     $module = array();
     if (count($map) > 0) {
         for ($i = 0; $i < count($map); $i++) {
             $file = APPPATH . DS . 'modules' . DS . $map[$i] . DS . $map[$i] . '.xml';
             if (file_exists($file)) {
                 $module[] = $map[$i];
             }
         }
     }
     // load modules info
     $this->load->library('xml');
     $xml = new Xml();
     $modules = array();
     $j = 0;
     for ($i = 0; $i < count($module); $i++) {
         $file = APPPATH . DS . 'modules' . DS . $module[$i] . DS . $module[$i] . '.xml';
         $data = $xml->parse($file);
         if (isset($data['name']) && $data['name'] != '' && isset($data['description']) && $data['description'] != '') {
             $modules[$j] = new stdclass();
             $modules[$j]->name = $module[$i];
             $modules[$j]->title = $data['name'];
             $modules[$j]->description = $data['description'];
             $modules[$j]->thumb = 'application/modules/' . $module[$i] . '/thumb.png';
             $j++;
         }
     }
     // get page layout
     $this->load->library('xml');
     $xml = new Xml();
     $file = APPPATH . DS . 'views' . DS . 'layouts' . DS . 'layouts.xml';
     $layouts = $xml->parse($file);
     $pages = array();
     if (count($layouts)) {
         $i = 0;
         //echo '<pre>'; print_r($layouts['group']); exit;
         foreach ($layouts['group'] as $group) {
             if (empty($group['@attributes']['description'])) {
                 continue;
             }
             $pages[$i] = new stdClass();
             $pages[$i]->name = $group['@attributes']['name'];
             $pages[$i]->description = $group['@attributes']['description'];
             if (empty($group['@attributes']['icon']) || $group['@attributes']['icon'] == '') {
                 $pages[$i]->icon = base_url('assets/images/system/home.png');
             } else {
                 $pages[$i]->icon = base_url('assets/images/system/' . $group['@attributes']['icon']);
             }
             $i++;
         }
     }
     $this->data['pages'] = $pages;
     $this->data['modules'] = $modules;
     $this->load->view('admin/module/index', $this->data);
 }
Exemplo n.º 9
0
 function insert_node($newXml)
 {
     if ($newXml) {
         $newNode = new Xml($newXml);
         $insertNode = $newNode->documentElement();
         $this->xml->documentElement->appendChild($this->xml->importNode($insertNode, true));
     }
 }
Exemplo n.º 10
0
 /**
  * parse() should return true if output if well-formed xml
  */
 public function test_parse_returnsTrue_ifOutputIsValidXml()
 {
     $xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<foo>' . '<bar>' . 'baz' . '</bar>' . '<bar>' . 'qux' . '</bar>' . '</foo>';
     $data = ['bar' => ['baz', 'qux']];
     $response = new Xml();
     $this->assertTrue($response->parse($xml));
     $this->assertEquals($data, $response->getData());
     return;
 }
Exemplo n.º 11
0
 /**
  * parse xml
  * 2010-02-07 ms
  */
 function parse($file)
 {
     App::import('Core', 'Xml');
     $xml = new Xml($file);
     $res = $xml->toArray();
     if (!empty($res['Xss']['Attack'])) {
         return (array) $res['Xss']['Attack'];
     }
     return array();
 }
Exemplo n.º 12
0
 /**
  * paginate
  *
  * @param  mixed $conditions
  * @param  mixed $fields
  * @param  mixed $order
  * @param  integer $limit
  * @param  integer $page
  * @param  integer $recursive
  * @param  array $extract
  * @return array
  */
 public function paginate($conditions, $fields, $order, $limit, $page, $recursive, $extra)
 {
     $HttpSocket = new HttpSocket();
     $query = array('q' => Set::extract('q', $conditions), 'page' => $page, 'rpp' => $limit, 'lang' => Set::extract('lang', $conditions));
     $ret = $HttpSocket->get(self::API_SEARCH, $query);
     if ($ret) {
         $Xml = new Xml($ret);
         return $Xml->toArray();
     }
     return array();
 }
Exemplo n.º 13
0
 /**
  * undocumented function
  *
  * @return void
  */
 function __tickets()
 {
     $this->out('This may take a while...');
     $project = @$this->args[1];
     $fork = null;
     if ($this->Project->initialize(compact('project', 'fork')) === false || $this->Project->current['url'] !== $project) {
         $this->err('Invalid project');
         return 1;
     }
     $path = $this->args[2];
     $ext = array_pop(explode('.', $path));
     if ($ext == 'xml') {
         App::import('Xml');
         $Xml = new Xml($path);
         $rows = array();
         $this->out('Importing Data...');
         foreach ($Xml->toArray() as $key => $data) {
             foreach ($data['Records']['Row'] as $columns) {
                 $new = array();
                 foreach ($columns['Column'] as $column) {
                     if ($column['name'] == 'created' || $column['name'] == 'modified') {
                         $column['value'] = date('Y-m-d H:i:s', $column['value']);
                     }
                     $new[$column['name']] = $column['value'];
                 }
                 $new['project_id'] = $this->Project->id;
                 $this->Ticket->create($new);
                 if ($this->Ticket->save()) {
                     $this->out('Ticket ' . $new['number'] . ' : ' . $new['title'] . ' migrated');
                     sleep(1);
                 }
             }
         }
         return 0;
     }
     $File = new File($path);
     $data = explode("\n", $File->read());
     $fields = explode(',', array_shift($data));
     foreach ($fields as $key => $field) {
         $fields[$key] = str_replace('"', '', $field);
     }
     pr($fields);
     $result = array();
     foreach ($data as $line) {
         $values = explode(',', $line);
         foreach ($values as $key => $value) {
             $field = str_replace('"', '', $fields[$key]);
             $result[$field] = str_replace('"', '', $value);
         }
     }
     pr($result);
 }
Exemplo n.º 14
0
 function valorFrete(&$model, $servico, $cepOrigem, $cepDestino, $peso, $maoPropria = false, $valorDeclarado = 0.0, $avisoRecebimento = false)
 {
     // Validação dos parâmetros
     $tipos = array(CORREIOS_SEDEX, CORREIOS_SEDEX_A_COBRAR, CORREIOS_SEDEX_10, CORREIOS_SEDEX_HOJE, CORREIOS_ENCOMENDA_NORMAL);
     if (!in_array($servico, $tipos)) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     $Validacao = new ValidacaoBehavior();
     if (!$Validacao->_cep($cepOrigem, '-') || !$Validacao->_cep($cepDestino, '-')) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     if (!is_numeric($peso) || !is_numeric($valorDeclarado)) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     if ($peso > 30.0) {
         return ERRO_CORREIOS_EXCESSO_PESO;
     } elseif ($peso < 0.0) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     if ($valorDeclarado < 0.0) {
         return ERRO_CORREIOS_PARAMETROS_INVALIDOS;
     }
     // Ajustes nos parâmetros
     if ($maoPropria) {
         $maoPropria = 'S';
     } else {
         $maoPropria = 'N';
     }
     if ($avisoRecebimento) {
         $avisoRecebimento = 'S';
     } else {
         $avisoRecebimento = 'N';
     }
     // Requisição
     $HttpSocket = new HttpSocket();
     $uri = array('scheme' => 'http', 'host' => 'www.correios.com.br', 'port' => 80, 'path' => '/encomendas/precos/calculo.cfm', 'query' => array('resposta' => 'xml', 'servico' => $servico, 'cepOrigem' => $cepOrigem, 'cepDestino' => $cepDestino, 'peso' => $peso, 'MaoPropria' => $maoPropria, 'valorDeclarado' => $valorDeclarado, 'avisoRecebimento' => $avisoRecebimento));
     $retornoCorreios = trim($HttpSocket->get($uri));
     if ($HttpSocket->response['status']['code'] != 200) {
         return ERRO_CORREIOS_FALHA_COMUNICACAO;
     }
     $Xml = new Xml($retornoCorreios);
     $infoCorreios = $Xml->toArray();
     if (!isset($infoCorreios['CalculoPrecos']['DadosPostais'])) {
         return ERRO_CORREIOS_CONTEUDO_INVALIDO;
     }
     extract($infoCorreios['CalculoPrecos']['DadosPostais']);
     return array('ufOrigem' => $uf_origem, 'ufDestino' => $uf_destino, 'capitalOrigem' => $local_origem == 'Capital', 'capitalDestino' => $local_destino == 'Capital', 'valorMaoPropria' => $mao_propria, 'valorTarifaValorDeclarado' => $tarifa_valor_declarado, 'valorFrete' => $preco_postal - $tarifa_valor_declarado - $mao_propria, 'valorTotal' => $preco_postal);
 }
 /**
  * Função para restauração
  */
 public function restore()
 {
     $sDiretorio = Configure::read('Cms.CheckPoint.menus');
     if (!is_dir($sDiretorio)) {
         $this->Session->setFlash("Diretório das restaurações não configurado.", 'default', array('class' => "alert alert-error"));
         $this->redirect(array('controller' => 'dashboard', 'action' => 'index'));
     }
     /**
      * Faz a restauração
      */
     if (!empty($this->data)) {
         $this->loadModel('Cms.Menu');
         App::import('Xml');
         $oSnapXml = new Xml($sDiretorio . $this->data['CheckPoint']['snapshot']);
         $aSnap = $oSnapXml->toArray();
         $aRestore = !empty($aSnap['Menus']) ? $aSnap['Menus']['Menu'] : array();
         /**
          * Verifica se possui apenas um item de menu no xml e trata de uma forma diferente.
          * -- Função de XML do Cake salva de formas diferentes o XML quando possui apenas um item.
          */
         if (!empty($aRestore) && !isset($aRestore[0])) {
             $aRestore = array($aRestore);
         }
         $this->CheckPoint->generate();
         if ($this->Menu->restauraBackup($aRestore)) {
             $this->Session->setFlash("Restaurado com sucesso.", 'default', array('class' => "alert alert-success"));
         } else {
             $this->Session->setFlash("Erro ao restaurar.", 'default', array('class' => "alert alert-error"));
         }
     }
     /**
      * Pega os snapshots salvos e invverte a ordem para exibir do mais novo para o mais antigo
      */
     $oFolder = new Folder(Configure::read('Cms.CheckPoint.menus'));
     $aFolder = $oFolder->read();
     $aFiles = array_reverse($aFolder[1]);
     $aSnapshot = array();
     foreach ($aFiles as $sFile) {
         if (!in_array($sFile, array('.', '..'))) {
             $aSnapshot[$sFile] = date('d/m/Y H:i:s', str_replace('.xml', '', $sFile));
         }
     }
     if (empty($aSnapshot)) {
         $this->Session->setFlash("Nenhum ponto de restauração encontrado.", 'default', array('class' => "alert alert-error"));
         $this->redirect(array('controller' => 'dashboard', 'action' => 'index'));
     }
     $this->set(compact('aSnapshot'));
 }
 /**
  * Displays the reCAPTCHA widget.
  * If $this->recaptcha_error is set, it will display an error in the widget.
  *
  */
 function getForm()
 {
     global $wgReCaptchaPublicKey, $wgReCaptchaTheme;
     $useHttps = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on';
     $js = 'var RecaptchaOptions = ' . Xml::encodeJsVar(array('theme' => $wgReCaptchaTheme, 'tabindex' => 1));
     return Html::inlineScript($js) . recaptcha_get_html($wgReCaptchaPublicKey, $this->recaptcha_error, $useHttps);
 }
Exemplo n.º 17
0
 /**
  * Serialize to array data from xml
  *
  * @param array $url url
  * @return array Xml serialize array data
  */
 public function serializeXmlToArray($url)
 {
     $xmlData = Xml::toArray(Xml::build($url));
     // rssの種類によってタグ名が異なる
     if (isset($xmlData['feed'])) {
         $items = Hash::get($xmlData, 'feed.entry');
         $dateKey = 'published';
         $linkKey = 'link.@href';
         $summaryKey = 'summary';
     } elseif (Hash::get($xmlData, 'rss.@version') === '2.0') {
         $items = Hash::get($xmlData, 'rss.channel.item');
         $dateKey = 'pubDate';
         $linkKey = 'link';
         $summaryKey = 'description';
     } else {
         $items = Hash::get($xmlData, 'RDF.item');
         $dateKey = 'dc:date';
         $linkKey = 'link';
         $summaryKey = 'description';
     }
     if (!isset($items[0]) && is_array($items)) {
         $items = array($items);
     }
     $data = array();
     foreach ($items as $item) {
         $date = new DateTime($item[$dateKey]);
         $summary = Hash::get($item, $summaryKey);
         $data[] = array('title' => $item['title'], 'link' => Hash::get($item, $linkKey), 'summary' => $summary ? strip_tags($summary) : '', 'last_updated' => $date->format('Y-m-d H:i:s'), 'serialize_value' => serialize($item));
     }
     return $data;
 }
	public function execute( $subpage ) {
		$this->setHeaders();

		$out = $this->getOutput();
		$out->addHTML( Xml::openElement( 'table', array( 'class' => 'wikitable' ) ) );

		$out->addHTML( '<thead>' );
		$out->addHTML( '<tr>' );
		$out->addHTML( '<th>' );
		$out->addWikiMsg( 'userdebuginfo-key' );
		$out->addHTML( '</th>' );
		$out->addHTML( '<th>' );
		$out->addWikiMsg( 'userdebuginfo-value' );
		$out->addHTML( '</th>' );
		$out->addHTML( '</tr>' );
		$out->addHTML( '</thead>' );

		$out->addHTML( '<tbody>' );

		$this->printRow( 'userdebuginfo-useragent', htmlspecialchars( $_SERVER['HTTP_USER_AGENT'] ) );

		if ( isset( $_SERVER['REMOTE_HOST'] ) ) {
			$this->printRow( 'userdebuginfo-remotehost', $_SERVER['REMOTE_HOST'] );
		}

		$this->printRow( 'userdebuginfo-remoteaddr', wfGetIP() );
		$this->printRow( 'userdebuginfo-language', htmlspecialchars( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) );

		$out->addHTML( '</tbody>' );
		$out->addHTML( '</table>' );
	}
Exemplo n.º 19
0
 /**
  * Create a redirect that is also valid JavaScript
  *
  * @param Title $destination
  * @param string $text ignored
  * @return JavaScriptContent
  */
 public function makeRedirectContent(Title $destination, $text = '')
 {
     // The parameters are passed as a string so the / is not url-encoded by wfArrayToCgi
     $url = $destination->getFullURL('action=raw&ctype=text/javascript', false, PROTO_RELATIVE);
     $class = $this->getContentClass();
     return new $class('/* #REDIRECT */' . Xml::encodeJsCall('mw.loader.load', [$url]));
 }
Exemplo n.º 20
0
function WidgetCategoryCloud($id, $params)
{
    $output = "";
    wfProfileIn(__METHOD__);
    global $wgMemc;
    $key = wfMemcKey("WidgetCategoryCloud", "data");
    $data = $wgMemc->get($key);
    if (is_null($data)) {
        $data = WidgetCategoryCloudCloudizeData(WidgetCategoryCloudGetData());
        $wgMemc->set($key, $data, 3600);
    }
    if (empty($data)) {
        wfProfileOut(__METHOD__);
        return wfMsgForContent("widget-categorycloud-empty");
    }
    foreach ($data as $name => $value) {
        $category = Title::newFromText($name, NS_CATEGORY);
        if (is_object($category)) {
            $class = "cloud" . $value;
            $output .= Xml::openElement("li", array("class" => $class));
            // FIXME fix Wikia:link and use it here
            $output .= Xml::element("a", array("class" => $class, "href" => $category->getLocalURL(), "title" => $category->getFullText()), $category->getBaseText());
            $output .= Xml::closeElement("li");
            $output .= "\n";
        }
    }
    if (empty($output)) {
        wfProfileOut(__METHOD__);
        return wfMsgForContent("widget-categorycloud-empty");
    }
    $output = Xml::openElement("ul") . $output . Xml::closeElement("ul");
    wfProfileOut(__METHOD__);
    return $output;
}
Exemplo n.º 21
0
 function doTagRow($tag, $hitcount)
 {
     $user = $this->getUser();
     $newRow = '';
     $newRow .= Xml::tags('td', null, Xml::element('code', null, $tag));
     $disp = ChangeTags::tagDescription($tag);
     if ($user->isAllowed('editinterface')) {
         $disp .= ' ';
         $editLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), $this->msg('tags-edit')->escaped());
         $disp .= $this->msg('parentheses')->rawParams($editLink)->escaped();
     }
     $newRow .= Xml::tags('td', null, $disp);
     $msg = $this->msg("tag-{$tag}-description");
     $desc = !$msg->exists() ? '' : $msg->parse();
     if ($user->isAllowed('editinterface')) {
         $desc .= ' ';
         $editDescLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), $this->msg('tags-edit')->escaped());
         $desc .= $this->msg('parentheses')->rawParams($editDescLink)->escaped();
     }
     $newRow .= Xml::tags('td', null, $desc);
     $active = isset($this->definedTags[$tag]) ? 'tags-active-yes' : 'tags-active-no';
     $active = $this->msg($active)->escaped();
     $newRow .= Xml::tags('td', null, $active);
     $hitcountLabel = $this->msg('tags-hitcount')->numParams($hitcount)->escaped();
     $hitcountLink = Linker::link(SpecialPage::getTitleFor('Recentchanges'), $hitcountLabel, array(), array('tagfilter' => $tag));
     // add raw $hitcount for sorting, because tags-hitcount contains numbers and letters
     $newRow .= Xml::tags('td', array('data-sort-value' => $hitcount), $hitcountLink);
     return Xml::tags('tr', null, $newRow) . "\n";
 }
 public function parseRss()
 {
     $channel = Xml::toArray(Xml::build($this->args[0])->channel);
     $items = $channel['channel']['item'];
     $list = $this->PinterestPin->find('list', array('fields' => array('id', 'guid')));
     $data = array();
     foreach ($items as $item) {
         if (!in_array($item['guid'], $list)) {
             $html = file_get_html($item['guid']);
             $image = $html->find('img.pinImage', 0);
             if (is_object($image)) {
                 $data[] = array('guid' => $item['guid'], 'title' => $item['title'], 'image' => $image->attr['src'], 'description' => strip_tags($item['description']), 'created' => date('Y-m-d H:i:s', strtotime($item['pubDate'])));
             }
         }
     }
     if (!empty($data)) {
         if ($this->PinterestPin->saveAll($data)) {
             $this->out(__d('pinterest', '<success>All records saved sucesfully.</success>'));
             return true;
         } else {
             $this->err(__d('pinterest', 'Cannot save records.'));
             return false;
         }
     }
     $this->out(__d('pinterest', '<warning>No records saved.</warning>'));
 }
Exemplo n.º 23
0
function PoemExtension($in, $param = array(), $parser = null)
{
    /* using newlines in the text will cause the parser to add <p> tags,
     * which may not be desired in some cases
     */
    $nl = isset($param['compact']) ? '' : "\n";
    if (method_exists($parser, 'recursiveTagParse')) {
        //new methods in 1.8 allow nesting <nowiki> in <poem>.
        $tag = $parser->insertStripItem("<br />", $parser->mStripState);
        $text = preg_replace(array("/^\n/", "/\n\$/D", "/\n/", "/^( +)/me"), array("", "", "{$tag}\n", "str_replace(' ','&nbsp;','\\1')"), $in);
        $text = $parser->recursiveTagParse($text);
    } else {
        $text = preg_replace(array("/^\n/", "/\n\$/D", "/\n/", "/^( +)/me"), array("", "", "<br />\n", "str_replace(' ','&nbsp;','\\1')"), $in);
        $ret = $parser->parse($text, $parser->getTitle(), $parser->getOptions(), true, false);
        $text = $ret->getText();
    }
    global $wgVersion;
    if (version_compare($wgVersion, "1.7alpha") >= 0) {
        // Pass HTML attributes through to the output.
        $attribs = Sanitizer::validateTagAttributes($param, 'div');
    } else {
        // Can't guarantee safety on 1.6 or older.
        $attribs = array();
    }
    // Wrap output in a <div> with "poem" class.
    if (isset($attribs['class'])) {
        $attribs['class'] = 'poem ' . $attribs['class'];
    } else {
        $attribs['class'] = 'poem';
    }
    return Xml::openElement('div', $attribs) . $nl . trim($text) . "{$nl}</div>";
}
Exemplo n.º 24
0
 public function getTag()
 {
     $this->wf->profileIn(__METHOD__);
     $imageHTML = $this->request->getVal('imageHTML');
     $align = $this->request->getVal('align');
     $width = $this->request->getVal('width');
     $showCaption = $this->request->getVal('showCaption', false);
     $caption = $this->request->getVal('caption', '');
     $zoomIcon = $this->request->getVal('zoomIcon', '');
     $showPictureAttribution = $this->request->getVal('showPictureAttribution', false);
     $attributeTo = $this->request->getVal('$attributeTo', null);
     $html = "<figure class=\"thumb" . (!empty($align) ? " t{$align}" : '') . " thumbinner\" style=\"width:{$width}px;\">{$imageHTML}{$zoomIcon}";
     if (!empty($showCaption)) {
         $html .= "<figcaption class=\"thumbcaption\">{$caption}";
     }
     //picture attribution
     if (!empty($showPictureAttribution) && !empty($attributeTo)) {
         $this->wf->profileIn(__METHOD__ . '::PictureAttribution');
         // render avatar and link to user page
         $avatar = AvatarService::renderAvatar($attributeTo, 16);
         $link = AvatarService::renderLink($attributeTo);
         $html .= Xml::openElement('div', array('class' => 'picture-attribution')) . $avatar . $this->wf->MsgExt('oasis-content-picture-added-by', array('parsemag'), $link, $attributeTo) . Xml::closeElement('div');
         $this->wf->profileOut(__METHOD__ . '::PictureAttribution');
     }
     if (!empty($showCaption)) {
         $html .= '</figcaption>';
     }
     $html .= '</figure>';
     $this->setVal('tag', $html);
     $this->wf->profileOut(__METHOD__);
 }
 /**
  * @param $user User
  * @param $output OutputPage
  */
 protected function showLogFragment($user, $output)
 {
     $pageTitle = Title::makeTitleSafe(NS_USER, $user->getName());
     $logPage = new LogPage('gblrights');
     $output->addHTML(Xml::element('h2', null, $logPage->getName()->text() . "\n"));
     LogEventsList::showLogExtract($output, 'gblrights', $pageTitle->getPrefixedText());
 }
Exemplo n.º 26
0
 function doTagRow($tag, $hitcount)
 {
     static $sk = null, $doneTags = array();
     if (!$sk) {
         $sk = $this->getSkin();
     }
     if (in_array($tag, $doneTags)) {
         return '';
     }
     global $wgLang;
     $newRow = '';
     $newRow .= Xml::tags('td', null, Xml::element('tt', null, $tag));
     $disp = ChangeTags::tagDescription($tag);
     $disp .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), wfMsgHtml('tags-edit')) . ')';
     $newRow .= Xml::tags('td', null, $disp);
     $msg = wfMessage("tag-{$tag}-description");
     $desc = !$msg->exists() ? '' : $msg->parse();
     $desc .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), wfMsgHtml('tags-edit')) . ')';
     $newRow .= Xml::tags('td', null, $desc);
     $hitcount = wfMsgExt('tags-hitcount', array('parsemag'), $wgLang->formatNum($hitcount));
     $hitcount = $sk->link(SpecialPage::getTitleFor('Recentchanges'), $hitcount, array(), array('tagfilter' => $tag));
     $newRow .= Xml::tags('td', null, $hitcount);
     $doneTags[] = $tag;
     return Xml::tags('tr', null, $newRow) . "\n";
 }
Exemplo n.º 27
0
 function show()
 {
     $out = $this->getOutput();
     $user = $this->getUser();
     // Header
     $out->addWikiMsg('abusefilter-tools-text');
     // Expression evaluator
     $eval = '';
     $eval .= AbuseFilter::buildEditBox('', 'wpTestExpr');
     // Only let users with permission actually test it
     if ($user->isAllowed('abusefilter-modify')) {
         $eval .= Xml::tags('p', null, Xml::element('input', array('type' => 'button', 'id' => 'mw-abusefilter-submitexpr', 'value' => $this->msg('abusefilter-tools-submitexpr')->text())));
         $eval .= Xml::element('p', array('id' => 'mw-abusefilter-expr-result'), ' ');
     }
     $eval = Xml::fieldset($this->msg('abusefilter-tools-expr')->text(), $eval);
     $out->addHTML($eval);
     $out->addModules('ext.abuseFilter.tools');
     if ($user->isAllowed('abusefilter-modify')) {
         // Hacky little box to re-enable autoconfirmed if it got disabled
         $rac = '';
         $rac .= Xml::inputLabel($this->msg('abusefilter-tools-reautoconfirm-user')->text(), 'wpReAutoconfirmUser', 'reautoconfirm-user', 45);
         $rac .= '&#160;';
         $rac .= Xml::element('input', array('type' => 'button', 'id' => 'mw-abusefilter-reautoconfirmsubmit', 'value' => $this->msg('abusefilter-tools-reautoconfirm-submit')->text()));
         $rac = Xml::fieldset($this->msg('abusefilter-tools-reautoconfirm')->text(), $rac);
         $out->addHTML($rac);
     }
 }
Exemplo n.º 28
0
 public function in_data()
 {
     $table = $_POST['table'];
     if (empty($table)) {
         $this->msg('文件夹名尚未填写!', 0);
     }
     $dir = __ROOTDIR__ . '/data/form/' . $table;
     $config = @Xml::decode(file_get_contents($dir . '/form.xml'));
     $config = $config['config'];
     if (empty($config)) {
         $this->msg('无法获取模型配置!', 0);
     }
     if (!file_exists($dir) || !file_exists($dir . '/dbbak/')) {
         $this->msg($table . '目录不存在!或者目录结构错误!', 0);
     }
     if (model('form')->table_info($config['table'])) {
         $this->msg($table . '表单已经存在,无法重复导入!', 0);
     }
     //导入数据库
     $db = new Dbbak($this->config['DB_HOST'], $this->config['DB_USER'], $this->config['DB_PWD'], $this->config['DB_NAME'], 'utf8', $dir . '/dbbak/');
     if (!$db->importSql('', $config['prefix'], $this->config['DB_PREFIX'])) {
         $this->msg('数据库导入失败!', 0);
     }
     //修改关联信息
     $info = model('form')->associate_edit();
     $this->msg('模型导入完毕!', 1);
 }
Exemplo n.º 29
0
 function doTagRow($tag, $hitcount)
 {
     static $sk = null, $doneTags = array();
     if (!$sk) {
         global $wgUser;
         $sk = $wgUser->getSkin();
     }
     if (in_array($tag, $doneTags)) {
         return '';
     }
     $newRow = '';
     $newRow .= Xml::tags('td', null, Xml::element('tt', null, $tag));
     $disp = ChangeTags::tagDescription($tag);
     $disp .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), wfMsg('tags-edit')) . ')';
     $newRow .= Xml::tags('td', null, $disp);
     $desc = wfMsgExt("tag-{$tag}-description", 'parseinline');
     $desc = wfEmptyMsg("tag-{$tag}-description", $desc) ? '' : $desc;
     $desc .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), wfMsg('tags-edit')) . ')';
     $newRow .= Xml::tags('td', null, $desc);
     $hitcount = wfMsg('tags-hitcount', $hitcount);
     $hitcount = $sk->link(SpecialPage::getTitleFor('RecentChanges'), $hitcount, array(), array('tagfilter' => $tag));
     $newRow .= Xml::tags('td', null, $hitcount);
     $doneTags[] = $tag;
     return Xml::tags('tr', null, $newRow) . "\n";
 }
	public static function getHTML( $file ){
		global $wgUser, $wgOut;
		
		// Add transcode table css and javascript:  
		$wgOut->addModules( array( 'ext.tmh.transcodetable' ) );
		
		$o = '<h2>' . wfMsgHtml( 'timedmedia-status-header' ) . '</h2>';
		// Give the user a purge page link
		$o.= self::$linker->link( $file->getTitle(), wfMsg('timedmedia-update-status'), array(), array( 'action'=> 'purge' ) );
		
		$o.= Xml::openElement( 'table', array( 'class' => 'wikitable transcodestatus' ) ) . "\n"
			. '<tr>'
			. '<th>'.wfMsgHtml( 'timedmedia-status' ) .'</th>'			
			. '<th>' . wfMsgHtml( 'timedmedia-transcodeinfo' ) . '</th>'
			. '<th>'.wfMsgHtml( 'timedmedia-direct-link' ) .'</th>';
			
		if( $wgUser->isAllowed( 'transcode-reset' ) ){
			$o.= '<th>' . wfMsgHtml( 'timedmedia-actions' ) . '</th>';
		}
			
		$o.= "</tr>\n";
			
		$o.= self::getTranscodeRows( $file );
		
		$o.=  Xml::closeElement( 'table' );
		return $o;
	}