https://stackoverflow.com/a/46140283/1559386
433675
function checkOutTag(repo, tag) {
  return git.Reference.dwim(repo, 'refs/tags/' + tag)
    .then(function(ref) {
      return ref.peel(git.Object.TYPE.COMMIT);
    })
    .then(function(ref) {
      return repo.getCommit(ref);
    })
    .then(function(commit) {
      return git.Checkout.tree(repo, commit, {
        checkoutStrategy: git.Checkout.STRATEGY.FORCE
      }).then(function() {
        return repo.setHeadDetached(commit, repo.defaultSignature, 'Checkout: HEAD ' + commit.id());
      });
    });
}
106120
function __content() // пока не используется, т.к. более древнее в base_object
	{
		if(($render_class = $this->render_class()))
		{
			if($render_class == 'self')
				$render = $this;
			elseif(!($render = bors_load($render_class)))
				debug_exit("Can't load global render engine {$render_class} for object '{$this}'");

			return $render->rendering($this);
		}
	}
1138223
public function api()
    {
        //处理消息
        $this->wechat->server->setMessageHandler(function ($m) {
            $this->m = $m;
            Log::info($m);

            if ($m->Event != 'unsubscribe' && $m->Event != 'LOCATION' && $m->Event != 'VIEW' && $m->Event != 'TEMPLATESENDJOBFINISH') {
                //存上行消息
                $msg = new Message();
                $msg->from_user_name = $m->FromUserName;
                $msg->to_user_name = $m->ToUserName;
                $msg->create_time = $m->CreateTime;
                $msg->msg_type = $m->MsgType;
//                $msg->msg_id = isset($m->MsgId) ? $m->MsgId : 0;
                $msg->content = isset($m->Content) ? $m->Content : '';
                $msg->pic_url = isset($m->PicUrl) ? $m->PicUrl : '';
//                $msg->location_x = isset($m->Location_X) ? $m->Location_X : '';
//                $msg->location_x = isset($m->Location_Y) ? $m->Location_Y : '';
//                $msg->scale = isset($m->Scale) ? $m->Scale : '';
                $msg->label = isset($m->Label) ? $m->Label : '';
                $msg->title = isset($m->Title) ? $m->Title : '';
                $msg->description = isset($m->Description) ? $m->Description : '';
                $msg->url = isset($m->Url) ? $m->Url : '';
                $msg->media_id = isset($m->MediaId) ? $m->MediaId : '';
                $msg->thumb_media_id = $m->ThumbMediaId;
                $msg->event = $m->Event;
                $msg->event_key = $m->EventKey;
                $msg->save();
            }

            //从上行消息中提取关键词
            $key = '';
            switch ($m->MsgType) {
                case 'text':
                    $key = $m->Content;

                    break;
                case 'event':
                    switch ($m->Event) {
                        case 'CLICK':
                            $key = $m->EventKey;
                            break;
                        case 'subscribe'://关注事件
                            UserSns::where('openid', $m->FromUserName)->update(['status' => 0]);
                            break;
                        case 'unsubscribe'://取消关注事件
                            UserSns::where('openid', $m->FromUserName)->update(['status' => 1]);
                            break;
                        case 'SCAN':
                    }
                    break;
            }
            $this->key = $key;
            Log::info($this->key);

//            //帮用户生成本站用户数据
//            if (!$this->reg()) {
//                return 'whops';
//            }

            //判断关注默认回复的关键词
            if ($m->Event == 'subscribe' && empty($m->EventKey)) {
                $this->key = $this->keyFollow;
            }

            //事件key会抽风夹带类似这种的 last_trade_no_4009012001201605306519754434
            if (strpos($m->EventKey, 'last_trade_no') === 0) {
                $this->key = $this->keyFollow;
            }

            //根据关键词处理回复
            $res = FALSE;
            if (!empty($this->key)) {
                $this->r = $this->returnReply();
            } else {
                $this->r = '';
            }

            //入库消息.取关和地理位置不记录

            return $this->r;

        });

        return $this->wechat->server->serve();

    }
1317518
function module_ex($module_name, $attrs)
	{
		$class_name = $this->class_name();
		$class_name = preg_replace('/_(main|edit|view)$/', '', $class_name);
		$module_class = \blib_grammar::plural($class_name).'_modules_'.$module_name;
		set_def($attrs, 'model', $this);
		$mod = bors_load_ex($module_class, $this, $attrs);
		if(!$mod)
			bors_throw(ec("Не могу загрузить модуль '$module_class'"));

		return $mod;
	}
12372
function(g,g2,x1,y1,x2,y2){
		// source側はtaranslateのぶん足されていないので、加算しておきます
		var sx1 = this.x0+x1*this.bw-1, sy1 = this.y0+y1*this.bh-1,
			sx2 = this.x0+x2*this.bw+2, sy2 = this.y0+y2*this.bh+2;
		if(sx1<0){ sx1=0;} if(sx2>g2.child.width) { sx2=g2.child.width;}
		if(sy1<0){ sy1=0;} if(sy2>g2.child.height){ sy2=g2.child.height;}
		g.drawImage(g2.child, sx1, sy1, (sx2-sx1), (sy2-sy1), sx1-this.x0, sy1-this.y0, (sx2-sx1), (sy2-sy1));
	}
1157586
private function sectionStdAdd()
	{
		/*
		 * Создаём список имеющихся шаблонов чтобы отфильтровать их из списка доступных.
		 */
		$templates = Templates::getInstance();
		$list = array_keys($templates->enum('std'));
		$existed = array();
		foreach ($list as $key)
		{
			$existed []= $key;
		}


		$values = array();
		$items = array();
		$jsArray = "var aTemplates = Array();\n";
		foreach ($this->stdTemplates as $key => $item)
		{
			if (in_array($key, $existed))
			{
				continue;
			}
			if (!isset($hint))
			{
				$hint = isset($item['hint']) ? $item['hint'] : '';
			}
			$values[] = $key;
			$items[] = $item['caption'];
			$jsArray .= "aTemplates['".$key."'] = '".(isset($item['hint'])?$item['hint']:'')."'\n";
		}
		if (!isset($hint))
		{
			$hint = '';
		}

		Eresus_Kernel::app()->getPage()->addScripts($jsArray."
			function onTemplateNameChange()
			{
				document.getElementById('templateHint').innerHTML =
					aTemplates[document.addForm.elements.namedItem('name').value];
			}
		");
		$form = array(
			'name' => 'addForm',
			'caption' => Eresus_Kernel::app()->getPage()->title.ADM_T_DIV.ADM_ADD,
			'width' => '100%',
			'fields' => array (
				array('type'=>'hidden','name'=>'action', 'value'=>'insert'),
				array('type'=>'hidden','name'=>'section', 'value'=>arg('section')),
				array('type'=>'select','name'=>'name','label'=>ADM_THEMES_TEMPLATE, 'values'=>$values,
					'items'=>$items, 'extra' => 'onChange="onTemplateNameChange()"'),
				array('type'=>'text','name'=>'hint', 'value' => $hint, 'extra' => 'id="templateHint"'),
				array('type'=>'memo','name'=>'code', 'height'=>'30', 'syntax' => 'html'),
			),
			'buttons' => array('ok','cancel'),
		);
		/* @var TAdminUI $page */
		$page = Eresus_Kernel::app()->getPage();
		$result = $page->renderForm($form);
		return $result;
	}
686954
function syntaxHighlight(json) {
  json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
    var cls = 'number',
        url = false;
    if (/^"/.test(match)) {
        if (/:$/.test(match)) {
          cls = 'key';
        } else {
          cls = 'string';
          if(match.indexOf('"https://') === 0){
            // url = true;
            cls += ' link';
          }
        }
    } else if (/true|false/.test(match)) {
      cls = 'boolean';
    } else if (/null/.test(match)) {
      cls = 'null';
    }
    var html = '<span class="' + cls + '">' + match + '</span>';
    if(url){
      html = '<a href>' + html + '</a>';
    }
    return html;
  });
}
1007627
function f_tahta_ihale_gizlenen_tumu(_tahta_id) {
        return f_tahta_ihale_gizlenen_idler(_tahta_id)
            .then(function (_ihale_idler) {
                if (_ihale_idler && _ihale_idler.length > 0) {
                    /** @type {OptionsIhale} */
                    var opts = {};
                    opts.bArrKalemleri = true;
                    opts.bYapanKurum = true;
                    opts.bTakip = true;
                    opts.optKalem.bArrTeklifleri = false;
                    opts.optKalem.bOnayDurumu = true;
                    opts.optKalem.bTakiptemi = true;
                    var db_ihale = require("./db_ihale");
                    return db_ihale.f_db_ihale_id(_ihale_idler, _tahta_id, opts);
                } else {
                    return [];
                }
            });
    }
435530
public function ajouter()
    {
        $authentifie = new archiAuthentification();
        $formulaire = new formGenerator();
        if ($authentifie->estConnecte()) {
            $tabForm=$this->getAdresseFields();
            $this->connexionBdd->getLock(array('historiqueAdresse'));
            $errors = $formulaire->getArrayFromPost($tabForm); // recupere les donnees POST suivant les champs de tabForm , tabForm est passé en référence, il contient donc les valeurs des champs a la sortie de la fonction
            $this->nettoieCoordonneesAdresse($tabForm); // permet de garder l'id de la rue, quartier, sousQuartier le plus bas dans la hierarchie , a partir duquel on peut retrouver le reste

            if (count($errors)==0) {
            // on regarde si l'adresse existe deja parmis les adresses valides (non "archivees")
                $sql = "SELECT ha1.idAdresse as idAdresse
						FROM historiqueAdresse ha1, historiqueAdresse ha2
						WHERE ha2.idAdresse = ha1.idAdresse
						AND ha1.idRue='".$tabForm['rue']['value']."'
								AND ha1.idSousQuartier='".$tabForm['sousQuartier']['value']."'
										AND ha1.idQuartier='".$tabForm['quartier']['value']."'
												AND ha1.idVille='".$tabForm['ville']['value']."'
														AND ha1.idPays='".$tabForm['pays']['value']."'
																AND ha1.numero = '".$tabForm['numero']['value']."'
																		AND ha1.date='".$tabForm['date']['value']."'
																				AND ha1.idIndicatif='".$tabForm['indicatif']['value']."'
																						GROUP BY ha1.idAdresse, ha1.idHistoriqueAdresse
																						HAVING ha1.idHistoriqueAdresse = max(ha2.idHistoriqueAdresse)";

                //debug($sql);

                $resCheckExist=$this->connexionBdd->requete($sql);

                if (mysql_num_rows($resCheckExist)>1) {
                    echo "plusieurs adresse existe concernant cette adresse, pas d'ajout, veuillez prevenir l'administrateur.<br>";
                } elseif (mysql_num_rows($resCheckExist)==1) {
                    echo "l'adresse existe deja dans la base";
                    // recuperation de l'id existant
                    $fetchAdresseExistante=mysql_fetch_array($resCheckExist);
                } else {
                    // ajout
                    // recherche du nouvel idAdresse
                    $resIdAdresse = $this->connexionBdd->requete("select max(idAdresse) as maxIdAdresse from historiqueAdresse");
                    $nouvelIdAdresse=0;
                    if (mysql_num_rows($resIdAdresse)>0) {
                        $fetchNouvelIdAdresse = mysql_fetch_array($resIdAdresse);
                        $nouvelIdAdresse = $fetchNouvelIdAdresse["maxIdAdresse"] + 1;
                    }

                    $sql = "INSERT INTO historiqueAdresse (idUtilisateur,idAdresse,date,description,nom,idRue,numero,idQuartier,idSousQuartier,idPays,idVille) VALUES (
							'".$authentifie->getIdUtilisateur()."',
							'".$nouvelIdAdresse."',
							\"".$this->date->toBdd($tabForm['date']['value'])."\",
							\"".$tabForm['description']['value']."\",
							\"".$tabForm['nom']['value']."\",
							'".$tabForm['rue']['value']."',
							'".$tabForm['numero']['value']."',
							'".$tabForm['quartier']['value']."',
							'".$tabForm['sousQuartier']['value']."',
							'".$tabForm['pays']['value']."',
							'".$tabForm['ville']['value']."'
							)";

                    $this->connexionBdd->requete($sql);

                    $cache = new cacheObject();
                    $cache->refreshCache();
                }
            } else {
                echo $this->afficheFormulaire($tabForm);
            }




            $this->connexionBdd->freeLock(array('historiqueAdresse'));
        } else {
            echo "erreur : Vous devez etre authentifié pour faire un ajout<br>";
        }
    }
283529
private function init_request()
	{
		global $request;

		# Значения по умолчанию
		$request = array(
			'method' => $_SERVER['REQUEST_METHOD'],
			'scheme' => isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 'https' : 'http',
			'host' => strtolower($_SERVER['HTTP_HOST']),
			'port' => '',
			'user' => isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : '',
			'pass' => isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : '',
			'path' => '',
			'query' => '',
			'fragment' => '',
			'referer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
		);

		$request['url'] = $request['scheme'] . '://' . $request['host'] . $_SERVER['REQUEST_URI'];

		$request = array_merge($request, parse_url($request['url']));
		$request['file'] = substr($request['path'], strrpos($request['path'], '/')+1);
		if ($request['file'])
		{
			$request['path'] = substr($request['path'], 0, -strlen($request['file']));
		}

		# Создаем заготовку URL для GET-запросов с параметрами
		$request['link'] = $request['url'];
		if (substr($request['link'], -1) == '/')
		{
			$request['link'] .= '?';
		}
		elseif (strpos($request['link'], '?') === false)
		{
			$request['link'] .= '?';
		}
		else
		{
			$request['link'] .= '&';
		}

		if (is_null($this->path))
		{
			$s = $this->froot;
			$s = substr($s,
				strlen(realpath($_SERVER['DOCUMENT_ROOT'])) - (Eresus_Kernel::isWindows() ? 2 : 0));
			if (!strlen($s) || substr($s, -1) != '/')
			{
				$s .= '/';
			}
			$this->path = (substr($s, 0, 1) != '/' ? '/' : '').$s;
		}

		/*
		 * Установка свойств объекта $Eresus
		 * Должна выполняться ДО вызова __clearargs
		 */
		$root = $request['scheme'] . '://' . $request['host'] .
			($request['port'] ? ':'.$request['port'] : '');
		$this->root = $root.$this->path;
		$this->data = $this->root.'data/';
		$this->style = $this->root.'style/';


		# Сбор аргументов вызова
		$request['arg'] = __clearargs(array_merge($_GET, $_POST));
		# Разбивка параметров вызова скрипта
		$s = substr($request['path'], strlen($this->path));
		$request['params'] = $s ? explode('/', substr($s, 0, -1)) : array();

		$request['path'] = $root.$request['path'];

		# Обратная совместимость
		# <= 2.9
		$this->request = &$request;
        /**
         * @deprecated с 3.01
         */
		define('httpPath', $this->path);
        /**
         * @deprecated с 3.01
         */
		define('httpHost', $this->request['host']);
        /**
         * @deprecated с 3.01
         */
        define('httpRoot', $this->root);
        /**
         * @deprecated с 3.01
         */
		define('styleRoot', $this->style);
        /**
         * @deprecated с 3.01
         */
		define('dataRoot', $this->data);
        /**
         * @deprecated с 3.01
         */
		define('cookieHost', $this->request['host']);
        /**
         * @deprecated с 3.01
         */
		define('cookiePath', $this->path);
	}
757909
public function showTrace()
    {
        $_trace =   array();
        $included_files = get_included_files();

        // 系统默认显示信息
        if (!empty($this->request->server['SCRIPT_NAME']))
        {
            $_trace['请求脚本'] = $this->request->server['SCRIPT_NAME'];
        }

        $_trace['请求方法'] = $this->swoole->env['mvc']['controller'].'/'.$this->swoole->env['mvc']['view'];
        $_trace['USER_AGENT'] = $this->request->server['HTTP_USER_AGENT'];
        $_trace['HTTP版本'] = $this->request->server['SERVER_PROTOCOL'];
        $_trace['请求时间'] = date('Y-m-d H:i:s', $this->request->server['REQUEST_TIME']);

        if (isset($_SESSION))
        {
            $_trace['SESSION_ID'] = session_id();
        }
        if ($this->swoole->db instanceof \Swoole\Database)
        {
            $_trace['读取数据库'] = $this->swoole->db->read_times . '次';
            $_trace['写入数据库'] = $this->swoole->db->write_times . '次';
        }
        $_trace['加载文件数目'] = count($included_files);
        $_trace['PHP执行占用'] = $this->showTime();
        $_trace = array_merge($this->traceInfo, $_trace);

        // 调用Trace页面模板
        $html = <<<HTMLS
<style type="text/css">
#swoole_trace_content  {
font-family:		Consolas, Courier New, Courier, monospace;
font-size:			14px;
background-color:	#fff;
margin:				40px;
color:				#000;
border:				#999 1px solid;
padding:			20px 20px 12px 20px;
}
</style>
	<div>
		<fieldset style="margin:5px;">
		<div style="overflow:auto;text-align:left;">
HTMLS;
        $html .= "<a href='".Tool::url_merge('_show_request', '1')."'>显示请求参数</a> |
        <a href='".Tool::url_merge('_show_session', '1')."'>显示会话信息</a> |
        <a href='".Tool::url_merge('_show_files', '1')."'>显示加载的PHP文件</a>
        <hr/>";
        foreach ($_trace as $key => $info)
        {
            $html .= $key . ' : ' . $info . BL;
        }
        if (!empty($this->request->get['_show_files']))
        {
            //输出包含的文件
            $html .= '加载的文件：' . BL."<pre style='color: #666'>";
            foreach ($included_files as $file)
            {
                $html .= $file . "\n";
            }
            $html .= "</pre>";
        }
        $html .= "</div></fieldset>";
        $html .= "</div>";

        if (!empty($this->request->get['_show_request']))
        {
            $output = '<fieldset style="margin:5px;"><div style="overflow:auto;text-align:left;">';
            $request = $this->swoole->request;
            $output .= "<h2>HEADER:</h2>".Tool::dump($request->header);
            $output .= "<h2>SERVER:</h2>".Tool::dump($request->server);
            if (!empty($request->files))
            {
                $output .= "<h2>FILE:</h2>".Tool::dump($request->files);
            }
            if (!empty($request->cookie))
            {
                $output .= "<h2>COOKIES:</h2>".Tool::dump($request->cookie);
            }
            if (!empty($request->get))
            {
                $output .= "<h2>GET:</h2>".Tool::dump($this->swoole->request->get);
            }
            if (!empty($request->post))
            {
                $output .= "<h2>POST:</h2>".Tool::dump($request->post);
            }

            $html .= $output."</div></fieldset>";
        }

        if (!empty($this->request->get['_show_session']))
        {
            $output = '<fieldset style="margin:5px;"><div style="overflow:auto;text-align:left;">';
            $this->session->start();
            $output .= "<h2>SESSION:</h2>" . Tool::dump($this->request->session);
            $html .= $output."</div></fieldset>";
        }

        return $html;
    }
1129372
public function dispatchAction()
    {
        //pobranie kategorii
        $category = $this->_getPublishedCategoryByUri($this->uri);
        //wpięcie kategorii do głównego widoku aplikacji
        FrontController::getInstance()->getView()->category = $category;
        //klucz bufora
        $cacheKey = 'category-html-' . $category->id;
        //buforowanie dozwolone
        $bufferingAllowed = $this->_bufferingAllowed();
        //wczytanie zbuforowanej strony (dla niezalogowanych i z pustym requestem)
        if ($bufferingAllowed && (null !== $html = \App\Registry::$cache->load($cacheKey))) {
            //wysyłanie nagłówka o buforowaniu strony
            $this->getResponse()->setHeader('X-Cache', 'HIT');
            //zwrot html
            return $this->_decorateHtmlWithEditButton($html, $category);
        }
        //wysyłanie nagłówka o braku buforowaniu strony
        $this->getResponse()->setHeader('X-Cache', 'MISS');
        //przekazanie rekordu kategorii do widoku
        $this->view->category = $category;
        //renderowanie docelowej akcji
        $html = \Mmi\Mvc\ActionHelper::getInstance()->forward($this->_prepareForwardRequest($category));
        //buforowanie niedozwolone
        if (!$bufferingAllowed || 0 == $cacheLifetime = $this->_getCategoryCacheLifetime($category)) {
            //zwrot html
            return $this->_decorateHtmlWithEditButton($html, $category);
        }
        //zapis html kategorii do cache
        \App\Registry::$cache->save($html, $cacheKey, $cacheLifetime);
        //zwrot html
        return $this->_decorateHtmlWithEditButton($html, $category);
    }
258342
function(){
		var lines = this.fstr.split("\n");
		var firstline = lines.shift();
		delete this.fstr;
		
		/* ヘッダからパズルの種類・ファイルの種類を判定する */
		if(firstline.match(/^pzprv3/)){
			this.type = FILE_PZPR;
			if(firstline.match(/pzprv3\.(\d+)/)){ this.filever = +RegExp.$1;}
			this.pid = lines.shift();
			this.qdata = lines.join("\n");
		}
		else if(firstline.match(/^\<\?xml/)){ // jshint ignore:line
			this.type = FILE_PBOX_XML;
			lines.unshift(firstline);
			this.qdata = lines.join("\n");
			if(!!DOMParser){
				this.body = (new DOMParser()).parseFromString(this.qdata, 'text/xml');
				this.pid = this.body.querySelector('puzzle').getAttribute('type');
			}
			else{ this.pid = '';}
		}
		else if(firstline.match(/^\d+$/)){
			this.type = FILE_PBOX;
			lines.unshift(firstline);
			this.qdata = lines.join("\n");
		}
		else{
			this.pid = '';
		}
		this.pid = pzpr.variety.toPID(this.pid);
		
		return (!!this.pid);
	}
1041368
function f_urun_ekle(_db_urun, _uretici_id, _tahta_id, _kul_id) {
        //l.info("f_db_urun_ekle");

        function f_urun_ekle(_db_urun, _uretici_id, _tahta_id, _kul_id) {
            //SON EKLENEN ürünün İD SİNİ ÇEK VE EKLEME İŞLEMİNE BAŞLA
            //l.info("f_urun_ekle");
            return result.dbQ.incr(result.kp.urun.idx)
                .then(function (_id) {
                    _db_urun.Id = _id;

                    return result.dbQ.hset(result.kp.urun.tablo, _id, JSON.stringify(_db_urun))
                        .then(function () {
                            if (_tahta_id && _tahta_id > 0) {
                                return result.dbQ.sadd(result.kp.tahta.ssetOzelUrunleri(_tahta_id, true), _id);
                            } else {
                                return _db_urun;
                            }
                        })
                        .then(function () {
                            if (_uretici_id && _uretici_id > 0) {

                                return result.dbQ.Q.all([
                                    result.dbQ.sadd(result.kp.kurum.ssetUrunleri(_tahta_id, _uretici_id), _id),
                                    result.dbQ.hset(result.kp.urun.hsetUreticiler, _id, _uretici_id),
                                    f_urun_iliskili_kurum_ekle(_tahta_id, _id, _uretici_id)
                                ])
                            } else {
                                return _db_urun;
                            }
                        })
                        .then(function () {
                            return f_urun_id(_db_urun.Id, _tahta_id)
                                .then(function (_dbUrun) {
                                    emitter.emit(schema.SABIT.OLAY.URUN_EKLENDI, _db_urun, _tahta_id, _kul_id);
                                    return _dbUrun;
                                });
                        });
                });
        }

        return Array.isArray(_db_urun)
            ? _db_urun.mapX(null, f_urun_ekle, _uretici_id, _tahta_id, _kul_id).allX()
            : f_urun_ekle(_db_urun, _uretici_id, _tahta_id, _kul_id);
    }
662785
public function index()
    {
        $oUri     = Factory::service('Uri');
        $oEmailer = Factory::service('Emailer', 'nails/module-email');
        $sRef     = $oUri->segment(3);
        $sGuid    = $oUri->segment(4);
        $sHash    = $oUri->segment(5);

        // --------------------------------------------------------------------------

        //  Fetch the email
        if (is_numeric($sRef)) {
            $oEmail = $oEmailer->getById($sRef);
        } else {
            $oEmail = $oEmailer->getByRef($sRef);
        }

        if (!$oEmail || !$oEmailer->validateHash($oEmail->ref, $sGuid, $sHash)) {
            show404();
        }

        if (Environment::is(Environment::ENV_DEV)) {

            $oAsset = Factory::service('Asset');
            $oAsset->load('debugger.min.css', 'nails/module-email');

            Factory::service('View')
                ->setData([
                    'oEmail' => $oEmail,
                ])
                ->load([
                    'structure/header/blank',
                    'email/view',
                    'structure/footer/blank',
                ]);

        } else {
            $oOutput = Factory::service('Output');
            $oOutput->set_output($oEmail->body->html);
        }
    }
101312
function(){
		var pzl = this, col = pzl.cols, row = pzl.rows, out = [];

		/* URLにつけるオプション */
		if(pzl.type!==URL_KANPEN && pzl.type!==URL_HEYAAPP){
			if(pzl.type===URL_KANPENP || !!pzl.pflag){ out.push(pzl.pflag);}
		}

		/* サイズを表す文字列 */
		if(pzl.type===URL_KANPEN){
			if(pzl.pid==="kakuro"){
				out.push(row + 1);
				out.push(col + 1);
			}
			else if(pzl.pid==="sudoku"){
				out.push(col);
			}
			else{
				out.push(row);
				out.push(col);
			}
		}
		else if(pzl.type===URL_HEYAAPP){
			out.push([col, row].join("x"));
		}
		else{
			out.push(col);
			out.push(row);
		}

		/* サイズ以降のデータを設定 */
		out.push(pzl.body);

		/* 末尾が0-9,a-z,A-Z以外の時にt.coで情報が欠落しないよう/を追加 */
		var body = out.join("/");
		if(!body.charAt(body.length-1).match(/[a-zA-Z0-9]/)){ body+='/';}
		return body;
	}
917885
public function delete()
    {
        // удаление ссылок с удаляемого материала
        $r = $this->getDbConnection()->query("select B.name, B.len, B.type, B.pseudo_type from types A, types_fields B where A.alias='".$this->table."' and B.id=A.id and (B.type=".FIELD_LINKSET." or B.type=".FIELD_MATSET.")");
        while ($f = $r->fetch(\PDO::FETCH_NUM)) {
            $tbl = ObjectDefinition::get_table($f[2], $f[1], $this->objectDefinition->id, $f[3]);
            if ($f[2] != FIELD_LINKSET && $f[3] != PSEUDO_FIELD_TAGS) {
            	$r1 = $this->getDbConnection()->query("select dest from ".$this->table."_".$tbl."_".$f[0]." where id=".$this->id);
            	while ($f1 = $r1->fetch(\PDO::FETCH_NUM)) {
            	   $m = Material::getById($f1[0], $f[1], $tbl);
            	   $m->delete();
            	}
            }
            $this->getDbConnection()->executeQuery("delete from ".$this->table."_".$tbl."_"."$f[0] where id=".$this->id);
        }
        
        // удаление ссылок на этот материал
        if (property_exists($this, 'idcat') && $this->idcat >= 0) {
        	$r = $this->getDbConnection()->query("select A.alias, B.name, B.type from types A, types_fields B where B.id=A.id and B.len=".$this->idcat." and (B.type=".FIELD_LINK." or B.type=".FIELD_LINKSET.")");
        	while ($f = $r->fetch(\PDO::FETCH_NUM)) {
              if ($f[2] == FIELD_LINK) {
        	    $this->getDbConnection()->executeQuery("update $f[0] set $f[1]=0 where $f[1]=".$this->id);
        	  } else {
        	    $this->getDbConnection()->executeQuery("delete from $f[0]"."_".$this->table."_"."$f[1] where dest=".$this->id);
        	  }
        	}
        } else {
        	$r = $this->getDbConnection()->query("select A.alias, B.name from types A, types_fields B where B.id=A.id and B.len = ".$this->objectDefinition->id." and B.type=".FIELD_MATSET);
            while ($f = $r->fetch(\PDO::FETCH_NUM)) {
        	  $this->getDbConnection()->executeQuery("delete from $f[0]"."_".$this->table."_"."$f[1] where dest=".$this->id);
        	}
        }
                
        // удаление самого материала
        $this->getDbConnection()->executeQuery("delete from ".$this->table." where id=".$this->id);
        
    }