/** * Update wrapper * @param \qio\Stream\Wrapper $wrapper */ public function setWrapper(Wrapper $wrapper) { if (is_null($this->stream)) { $this->setStream($wrapper->getStream()); } $this->wrapper = $wrapper; }
public function render() { try { $template = ''; if ($this->template != '') { ob_start(); include APP_ROOT . 'pages' . DS . 'template' . DS . $this->template; $template .= ob_get_clean(); } if (!empty($this->childs)) { foreach ($this->childs as $child) { $childTemplate = $child->render(); $mark = strpos($template, '[?' . $child->getName() . '?]'); if ($mark == false) { $template .= $childTemplate; } else { $template = str_replace('[?' . $child->getName() . '?]', $childTemplate, $template); } } } if ($this->wrapper != '') { $wrapper = new Wrapper($this->wrapper, $template); $template = $wrapper->render(); } return $template; } catch (Exception $e) { echo $e->getMessage(), "\n"; } }
/** * Wrap a template * @param Template $view * @return Template */ public function wrap(Template $view) { $template = $this->getTemplate(); $template->set('next', $view); if (!$this->wrapper) { return $template; } return $this->wrapper->wrap($template); }
/** * validates getErrors works as expected * * @author Daniel Sherman * @test * @depends testConstruct * @covers ::getErrors */ public function testGetErrors() { $rules = [0 => new Caller('is_string', 'input is not a string'), 1 => new Caller(function ($email) { $regex = ";^[a-z0-9!#\$%&'*+/\\=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'*+/\\=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\$;i"; if (preg_match($regex, $email) === 1) { return true; } return false; }, 'input is not a valid email address')]; $msg = 'The wrapper error message'; $test = new Wrapper($rules, $msg); $this->assertEquals([$msg], $test->getErrors()); }
public static function sideMenu() { include_once '../model/Mlogin.php'; $user = $_SESSION['mathmlusr']; $id = Mlogin::getId($user); $page = explode("V", $_SERVER['PHP_SELF'])[1]; $my = $collection = $search = ""; switch ($page) { case "my.php": $my = 'style="color:#32475e;border-right:5px solid #e74d3d"'; break; case "collection.php": $collection = 'style="color:#32475e;border-right:5px solid #e74d3d"'; break; case "search.php": $search = 'style="color:#32475e;border-right:5px solid #e74d3d"'; break; default: break; } echo '<div id="sidebar"> <ul> <a href="Vmy.php"><li ' . $my . '>Moji izrazi <img height="22" src="../images/home.png" class="user" /></li></a> <a href="Vcollection.php"><li ' . $collection . '>Kolekcija <img height="22" src="../images/flag.png" class="user" /></li></a>'; if (Wrapper::online()) { echo '<a href="Vsearch.php"><li ' . $search . '>Pretraga <img height="22" src="../images/search.png" class="user" /></li></a>'; } echo '</ul> </div>'; }
public static function getInstance() { if (self::$_instance == null) { self::$_instance = new Wrapper(); } return self::$_instance; }
public function logout() { $u = User::getInstance(); $wrapper = Wrapper::getInstance(); $this->set('data', $wrapper->user($u)); $this->ApiSession->logout(); }
public function testWrap() {/*{{{*/ $dir = dirname(__FILE__); $wrapper = new Wrapper; $xsltFile = $dir.'/demo.xslt'; $xmlFile = $dir.'/demo.xml'; $result = $wrapper->wrap($xsltFile, $xmlFile); $expectedRes = '<?xml version="1.0" encoding="gbk"?> <document> <item> <hospitalfacultyname>testÒ½Ôºtest¿Æ</hospitalfacultyname> <url>www.haodf.com</url> </item> </document>'; $resArray = XString::xmlToArray($result); $expectedResArray = XString::xmlToArray($expectedRes); $this->assertEquals($expectedResArray, $resArray); }/*}}}*/
public function stream_write($data) { $bytesToSend = strlen($data); $result = parent::stream_write($data); while ($result < $bytesToSend && !$this->stream_eof()) { $dataLeft = substr($data, $result); $result += parent::stream_write($dataLeft); } return $result; }
protected function validateFilter() { if (isset($this->_options['float'])) { $filter = FILTER_VALIDATE_FLOAT; $this->_options['decimal'] = true; } else { $filter = FILTER_VALIDATE_INT; } return parent::validateFilter($filter, 'Invalid Number'); }
public static function form($fid) { include_once '../model/Mwrapper.php'; include_once '../model/Mlogin.php'; include_once '../model/Msearch.php'; $res = Mexpression::getExpression($fid); if ($res['verified'] == 1) { $verified = "<img src='../images/verified.png' style='height:36px;margin-bottom:-5px;' />"; } else { $verified = ""; } $acc = Mlogin::getAccForId($res['accid']); echo "<h5 style='color:#b3b3b3'>" . $acc['username'] . "</h5>"; echo "<h1 style='color:#32475e;'>{$verified}" . $res['name'] . " <span style='color:#b3b3b3;font-size:26px'>[" . $res['popularity'] . "]</span></h1>"; echo "<div class='formula'>`" . $res['formula'] . "`</div>"; echo "<p id='desc'>" . Msearch::filterText($res['description']) . "</p>"; if (Wrapper::online()) { $accid = Mlogin::getId($_SESSION['mathmlusr']); if (Mexpression::mine($accid, $fid) == 1) { echo '<img style="height:22px;margin-right:60px;" src="../images/edit.png" class="user" />'; echo "<a href='../view/Vnew.php?id=" . $res['id'] . "' style='color:#e74d3d;float:right;'>IZMENI</a>"; echo '<img height="22" src="../images/delete.png" class="user" />'; echo "<a href='../script/Sdelete.php?id=" . $res['id'] . "' style='color:#e74d3d;float:right;' onclick='" . 'return confirm("Da li ste sigurni da želite da obrišete ovaj izraz?");' . "'>OBRIŠI</a>"; } else { if (Mexpression::isAdded($accid, $fid) == 1) { $value = "BRIŠI IZ KOLEKCIJE"; } else { $value = "DODAJ U KOLEKCIJU"; } echo "<input type='submit' id='save' value='{$value}' data-fid='{$fid}' />"; } } echo "<span class='heading'>AsciiMath</span>\n <pre><code id='asciimath' disabled='true' class='exp-area'>" . $res['formula'] . "</code></pre>\n\t\t <span class='heading'>LaTeX</span>\n <pre><code id='latex' disabled='true' class='exp-area tex'></code></pre>\n\t\t\t<span class='heading'>Presentation MathML</span>\n <pre><code id='mathml' disabled='true' class='exp-area html'></code></pre>"; echo "<input type='button' id='export' value='Preuzmi izvorni kod' />"; if ($res['content'] != "") { echo "<span class='heading'>Content MathML</span>\n <pre><code disabled='true' class='exp-area html'>" . htmlspecialchars($res['content']) . "</code></pre>"; echo "<span class='heading' id='label' data-curr='mml'>Unesi vrednosti</span>"; echo "<div id='var' style='float:left;width:100%;'>"; Mexpression::getCi($res['content']); echo " <br /><input type='submit' id='compute' data-id='" . $res['id'] . "' value='IZRAČUNAJ' />"; echo "</div>"; echo "<span class='heading' id='result'></span>\n\t\t\t\t <div style='display:none;'>`" . $res['formula'] . "`</div>"; } }
public function root() { App::import("vendor", "model/section"); $secs = Configure::read('section'); $wrapper = Wrapper::getInstance(); $data = array(); foreach (array_keys($secs) as $v) { try { $sec = Section::getInstance($v, Section::$NORMAL); } catch (SectionNullException $e) { $this->error(ECode::$SEC_NOSECTION); } catch (BoardNullException $e) { $this->error(ECode::$BOARD_NOBOARD); } $data[] = $wrapper->section($sec, array('status' => true)); } $data = array('section_count' => count($data), 'section' => $data); $this->set('data', $data); $this->set('root', 'sections'); }
function __construct($text) { self::$patterns = array('#http://www\\.dailymotion\\.com/video/(?<id>[a-zA-Z0-9]+)_#', '#http://www\\.dailymotion\\.com/[a-z]+/video/(?<id>[a-zA-Z0-9]+)#'); parent::__construct($text); if (!$this->info) { $pattern = '#http://www\\.dailymotion\\.com/video/([a-zA-Z0-9]+)#'; if (preg_match($pattern, $text, $match)) { $long_id = $match[1]; $url = 'https://api.dailymotion.com/video/' . $long_id; $cache_id = md5($url); if (!($data = $this->cache->get($cache_id))) { $data = json_decode(file_get_contents($url)); if ($data) { $this->cache->set($cache_id, $data); } } $this->info = array('id' => $data->id); } } }
/** * prepare tab content element * @param $objElement */ public function __construct($objElement) { parent::__construct($objElement); // load tab definitions if ($this->objWrapper->getType() == ContentWrapper\Model::TYPE_START) { $tabs = deserialize($this->tabs, true); $tab = null; foreach ($tabs as $i => $t) { $tabs[$i]['id'] = standardize($t['title']); if ($t['type'] != 'dropdown' && $tab === null) { $tab = $tabs[$i]; } } $this->arrTabs = $tabs; $this->arrTab = $tab; $this->fade = $this->bootstrap_fade; } elseif ($this->objWrapper->getType() == ContentWrapper\Model::TYPE_SEPARATOR) { $elements = $this->Database->prepare('SELECT id FROM tl_content WHERE bootstrap_parentId=? ORDER by sorting')->execute($this->bootstrap_parentId); /** @var \Database\Result $elements */ $elements = array_merge(array($this->bootstrap_parentId), $elements->fetchEach('id')); $index = 0; $parent = \ContentModel::findByPK($this->bootstrap_parentId); if ($parent) { $parent = new ContentWrapper\Model($parent); $this->fade = $parent->bootstrap_fade; } $tabs = deserialize($parent->bootstrap_tabs, true); foreach ($tabs as $i => $t) { $tabs[$i]['id'] = standardize($t['title']); if ($t['type'] != 'dropdown') { if ($elements[$index] == $this->id) { $this->arrTab = $tabs[$i]; } $index++; } } $this->arrTabs = $tabs; } }
public function index() { $wrapper = Wrapper::getInstance(); $data = array(); $data = $wrapper->board($this->_board, array('status' => true)); App::import('vendor', 'inc/pagination'); $count = isset($this->params['url']['count']) ? $this->params['url']['count'] : Configure::read("pagination.threads"); $page = isset($this->params['url']['page']) ? $this->params['url']['page'] : 1; if (($count = intval($count)) <= 0) { $count = Configure::read("pagination.threads"); } if ($count > Configure::read('plugins.api.page_item_limit')) { $count = Configure::read("pagination.article"); } $page = intval($page); $pagination = new Pagination($this->_board, $count); $articles = $pagination->getPage($page); $data['pagination'] = $wrapper->page($pagination); foreach ($articles as $v) { $data['article'][] = $wrapper->article($v, array('threads' => $this->_board->getMode() == Board::$THREAD)); } $this->set('data', $data); }
public function stream_eof() { return parent::stream_eof() and ftell($this->source) === ftell($this->cache); }
public static function isValid($data) { return parent::_isValid(__CLASS__, $data); }
/** * {@inheritdoc} */ public function __construct($codeStore, $nameMangler, $lobAsString) { parent::__construct($codeStore, $nameMangler, $lobAsString); $this->exceptions[] = 'ResultException'; $this->imports[] = 'SetBased\\Stratum\\Exception\\ResultException'; }
/** * Remove this job from the queue */ public function remove() { if (isset($this->job_number)) { Wrapper::removeJob((int) $this->job_number); } }
public function ajax_single() { if (!isset($this->params['id'])) { $this->error(ECode::$ARTICLE_NONE); } $id = $this->params['id']; try { $article = Article::getInstance($id, $this->_board); } catch (ArticleNullException $e) { $this->error(ECode::$ARTICLE_NONE); } App::import('vendor', 'inc/wrapper'); $wrapper = Wrapper::getInstance(); $ret = $wrapper->article($article, array('single' => true, 'content' => false)); $u = User::getInstance(); $ret['allow_post'] = $this->_board->hasPostPerm($u); $ret['is_bm'] = $u->isBM($this->_board) || $u->isAdmin(); $content = $article->getHtml(true); if (Configure::read("ubb.parse")) { //remove ubb of nickname in first and title second line preg_match("'^(.*?<br \\/>.*?<br \\/>)'", $content, $res); $content = preg_replace("'(^.*?<br \\/>.*?<br \\/>)'", '', $content); $content = XUBB::remove($res[1]) . $content; $content = XUBB::parse($content); } $ret['content'] = $content; $this->set('no_html_data', $ret); }
public function ajax_show() { App::import('Sanitize'); $level = $this->params['num']; try { $fav = Favor::getInstance($level); } catch (FavorNullException $e) { $this->error(ECode::$USER_FAVERROR); } $this->cache(false); $ret = array(); App::import('vendor', 'inc/wrapper'); $wrapper = Wrapper::getInstance(); if (!$fav->isNull()) { $brds = $fav->getAll(); $u = User::getInstance(); foreach ($brds as $k => $v) { $last = array(); $last["id"] = $last["title"] = $last["owner"] = $last["date"] = false; if ($v->hasReadPerm($u)) { $threads = $v->getTypeArticles(0, 1, Board::$ORIGIN); if (!empty($threads)) { $threads = $threads[0]; $last = array("id" => $threads->ID, "title" => Sanitize::html($threads->TITLE), "owner" => $threads->isSubject() ? $threads->OWNER : "ÔÌûÒÑɾ³ý", "date" => date("Y-m-d H:i:s", $threads->POSTTIME)); } } if ($v->NAME == '') { $v = $wrapper->favorite($v); $v['type'] = 'fav'; $v['name'] = $v['level']; } else { if ($v->isDir()) { $v = $wrapper->section(Section::getInstance($v)); $v['type'] = 'section'; } else { $v = $wrapper->board($v, array('status' => true)); $v['type'] = 'board'; } } $v['last'] = $last; $ret[] = $v; continue; $ret[$k]['name'] = $v->NAME; $ret[$k]['desc'] = $v->DESC; $ret[$k]['dir'] = $v->isDir() ? 1 : 0; $ret[$k]['class'] = $v->CLASS; $ret[$k]['bm'] = $v->BM; $ret[$k]['pos'] = $v->NPOS; $ret[$k]['bid'] = $v->BID; $ret[$k]['num'] = $v->ARTCNT; //article num $ret[$k]['pnum'] = $v->CURRENTUSERS; //online $ret[$k]['tnum'] = $v->getTodayNum(); //totay article num $ret[$k]['thnum'] = $v->getThreadsNum(); //threads num $ret[$k]['last'] = $last; //last post $ret[$k]['link'] = ($v->isDir() ? "/fav/" : "/board/") . $v->BID; } } $this->set('no_html_data', $ret); //no ajax status info $this->set('no_ajax_info', true); }
require_once DATA_PATH . 'Donnees.inc.php'; abstract class Wrapper { // This class is just a wrapper to access data (in data/Donnees.inc.php) more conveniently and more importantly in the same way as the other Objects ! // Variables protected $key; public static $recipesData; public static $hierarchyData; // Helpers public static function getDataAt($key) { return self::$data[$key]; } private function getData() { return self::getDataAt($this->key); } // Constructors public function __construct($key) { $this->key = $key; } // Getters public function getId() { return $this->key; } } Wrapper::$recipesData = $Recettes; Wrapper::$hierarchyData = $Hierarchie;
/** {@inheritdoc} */ public function getMetaData($path) { $this->checkAvailability(); try { return parent::getMetaData($path); } catch (\OCP\Files\StorageNotAvailableException $e) { $this->setAvailability(false); throw $e; } }
public function delete() { if (!$this->RequestHandler->isPost()) { $this->error(ECode::$SYS_REQUESTERROR); } if (!isset($this->params['type'])) { $this->error(ECode::$MAIL_NOBOX); } if (!isset($this->params['num'])) { $this->error(ECode::$MAIL_NOMAIL); } $type = $this->params['type']; $num = $this->params['num']; try { $box = new MailBox(User::getInstance(), $type); $mail = Mail::getInstance($num, $box); $wrapper = Wrapper::getInstance(); $data = $wrapper->mail($mail); if (!$mail->delete()) { $this->error(ECode::$MAIL_DELETEERROR); } } catch (MailBoxNullException $e) { $this->error(ECode::$MAIL_NOBOX); } catch (MailNullException $e) { $this->error(ECode::$MAIL_NOMAIL); } catch (Exception $e) { $this->error(ECode::$MAIL_DELETEERROR); } $this->set('data', $data); }
public function __construct($file, $bare = true) { parent::__construct($file); $this->bare = $bare; }
<?php $a = array("action" => "find_data", "request" => array("currentPage" => 2, "pcsPerPage" => 5, "shownPages" => 3, "ascending" => TRUE, "tableName" => "pager", "sorter" => "id")); /*$a=json_decode($_POST['data']);*/ if ($a['action'] == 'find_data') { include "conditioner.class.php"; $b = new Wrapper(); foreach ($a["request"] as $key => $value) { $b->{$key} = $value; } } $output = $b->get_data(); /*$output=json_encode($b); return ($output)*/ print_r($output);
<?php session_start(); include_once "../model/Mwrapper.php"; include_once "../model/Mlogin.php"; include_once "../model/Mhome.php"; include_once "../model/Mregister.php"; include_once "../model/Msearch.php"; //if (!Wrapper::online()) header("Location: ../index.php"); Wrapper::begin(["mathmlf();", "exportm();"]); Wrapper::contentBegin(); if (Wrapper::online()) { Wrapper::sideMenu(); } Wrapper::centerBegin(); Mhome::form(); Wrapper::centerEnd(); if (!Wrapper::online()) { Mregister::form(); Mlogin::form(); Msearch::notOnlineLink(); } Wrapper::contentEnd(); Wrapper::end();
public function category() { $category = $this->params['id']; $params = array(); $time = time(); $yes = $time - 86400; $u = User::getInstance(); switch ($category) { case 'hot': $sql = "select * from pl_vote where status=1 and end>? order by num desc, vid desc"; $params = array($yes); break; case 'me': case 'list': if ($category === 'me') { $user = $u->userid; } else { @($user = trim($this->params['url']['u'])); } $sql = "select * from pl_vote where status=1 and uid=? order by vid desc"; $params = array($user); break; case 'all': $sql = "select * from pl_vote where status=1 order by vid desc"; break; case 'join': $this->requestLogin(); $sql = "select * from pl_vote where status=1 and vid in (select vid from pl_vote_result where uid=?) order by vid desc"; $params = array($u->userid); break; case 'delete': if (!$u->isAdmin()) { $this->error('你无权查看此类投票'); } $sql = "select * from pl_vote where status=0 order by vid desc"; break; case 'new': $category = "new"; $sql = "select * from pl_vote where status=1 and end>? order by vid desc"; $params = array($yes); break; default: $this->error('错误的类别'); } $list = new VoteList($sql, $params); App::import('vendor', 'inc/pagination'); $count = isset($this->params['url']['count']) ? $this->params['url']['count'] : 10; $page = isset($this->params['url']['page']) ? $this->params['url']['page'] : 1; if (($count = intval($count)) <= 0) { $count = 10; } if ($count > Configure::read('plugins.api.page_item_limit')) { $count = Configure::read('plugins.api.page_item_limit'); } $page = intval($page); $pagination = new Pagination($list, $count); $votes = $pagination->getPage($page); $wrapper = Wrapper::getInstance(); $data = array(); $data['pagination'] = $wrapper->page($pagination); $data['votes'] = array(); foreach ($votes as $v) { $data['votes'][] = $wrapper->vote($v); } $this->set('data', $data); $this->set('root', 'list'); }
function testAOP() { // test aop 测试入口 $aop = Wrapper::wrap(new AOPWorker()); $aop->testAOP(33347); }
function __construct($text) { self::$patterns = array('#https?://vimeo.com/(?<id>[0-9]+)#', '#https?://vimeo.com/channels/.*?/(?<id>[0-9]+)#', '#https?://vimeo.com/groups/.*?/videos/(?<id>[0-9]+)#'); $this->options += array('byline' => 0, 'portrait' => 0); parent::__construct($text); }