/** * @see Page::readParameters */ public function readParameters() { // if there is no user logged in try to get valid logindata if (!WCF::getUser()->userID && function_exists('getallheaders')) { if (!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['PHP_AUTH_PW'])) { $this->authenticate(); } else { $this->user = new UserSession(null, null, $_SERVER['PHP_AUTH_USER']); if (!$this->user->checkPassword($_SERVER['PHP_AUTH_PW'])) { $this->authenticate(); } } } else { $this->user = WCF::getUser(); } $sourceID = 0; if (isset($_REQUEST['sourceID'])) { $sourceID = $_REQUEST['sourceID']; } if (isset($_REQUEST['type'])) { $this->type = StringUtil::trim($_REQUEST['type']); } if (!in_array($this->type, $this->validTypes)) { throw new IllegalLinkException(); } $this->source = new Source($sourceID); if (!$this->source->sourceID) { throw new IllegalLinkException(); } if (!$this->source->hasAccess($this->user)) { throw new PermissionDeniedException(); } }
public function getList($script) { if (isset($this->hash[$script])) { return array(); } $this->hash[$script] = true; $result = array(); if (!file_exists($script)) { throw new \Exception(sprintf('File %s not found', $script)); } $contents = file_get_contents($script); $result[] = $script; foreach ($this->getScriptDependencies($contents) as $class) { if (strpos($class, 'Ext.') !== 0) { $file = $this->source->getClassFile($class); if (!in_array($file, $result)) { $result[] = $file; } foreach ($this->getList($file) as $dependency) { if (!in_array($dependency, $result)) { $result[] = $dependency; } } } } return $result; }
/** * Build the project * @return void */ public function build() { $source = new Source($this->_source); foreach ($source->getFiles() as $file) { $this->copyFile(str_replace($this->_source, '', $file)); } }
public function testGetContent() { $this->source->expects($this->exactly(2))->method('getContent')->with($this->object)->will($this->returnValue('content')); $this->assertEquals('content', $this->object->getContent()); $this->assertEquals('content', $this->object->getContent()); // no in-memory caching for content }
/** * @access public * @return void * @depricated */ public function forecast() { if ($this->_validateRequest() !== False) { $this->_populate($this->input->post()); $source = new Source($this->_request); echo json_encode($source->gatherForecast()); exit; } }
/** * @param Source $source * @param $position * @param $description * @return Exception */ public static function create(Source $source, $position, $description) { $location = $source->getLocation($position); $syntaxError = new self("Syntax Error {$source->name} ({$location->line}:{$location->column}) {$description}\n\n" . self::highlightSourceAtLocation($source, $location)); $syntaxError->source = $source; $syntaxError->position = $position; $syntaxError->location = $location; return $syntaxError; }
/** * @see DatabaseObjectList::readObjects() */ public function readObjects() { $sql = "SELECT\t\t" . (!empty($this->sqlSelects) ? $this->sqlSelects . ',' : '') . "\n\t\t\t\t\tsource.*\n\t\t\tFROM\t\tpb" . PB_N . "_source source\n\t\t\t" . $this->sqlJoins . "\n\t\t\t" . (!empty($this->sqlConditions) ? "WHERE " . $this->sqlConditions : '') . "\n\t\t\t" . (!empty($this->sqlOrderBy) ? "ORDER BY " . $this->sqlOrderBy : ''); $result = WCF::getDB()->sendQuery($sql, $this->sqlLimit, $this->sqlOffset); while ($row = WCF::getDB()->fetchArray($result)) { $source = new Source(null, $row); if (!$this->hasAccessCheck || $source->hasAccess()) { $this->sources[] = $source; } } }
function setup_edit() { $l = new Source(); $l->setFromRequest(); $ret = $l; if ($l->source_id != '' && $l->source_id > 0) { $dao = getSourceDAO(); $dao->getSources($l); if ($l->numResults > 0) { $ret = $l->results[0]; } } return $ret; }
/** * @see Page::readParameters() */ public function readParameters() { $sourceID = 0; if (isset($_GET['sourceID'])) { $sourceID = $_GET['sourceID']; } $this->source = new Source($sourceID); if (!$this->source->sourceID) { throw new IllegalLinkException(); } if (!$this->source->hasAccess()) { throw new PermissionDeniedException(); } }
public function __construct($media, $srcset, $type = null) { if (is_int($media)) { $media = "(min-width: {$media}px)"; } parent::__construct($media, $srcset, $type); }
/** * @see Action::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_POST['filename'])) { $this->filename = StringUtil::trim($_POST['filename']); } if (isset($_POST['saveSelection'])) { $this->saveSelection = true; } if (isset($_POST['sourceID'])) { $this->sourceID = intval($_POST['sourceID']); } if (isset($_POST['wcfSetupResource'])) { $this->wcfSetupResource = StringUtil::trim($_POST['wcfSetupResource']); // override package name if building WCFSetup $this->filename = 'pn'; } $this->source = new Source($this->sourceID); if (!$this->source->sourceID) { throw new IllegalLinkException(); } if (!$this->source->hasAccess()) { throw new PermissionDeniedException(); } // read selected resources $this->readPackageSelection(); // handle current directory resource $sourceData = WCF::getSession()->getVar('source' . $this->source->sourceID); if ($sourceData === null) { throw new SystemException('Resource directory missing'); } $sourceData = unserialize($sourceData); $this->directory = $sourceData['directory']; }
public function withAuthors() { if ($this->id) { $this->authors = Source::getInstance()->getAllAuthors($this->id); } return $this; }
public function __construct($type, $args) { parent::__construct($type, $args); if (!isset($args['db-name'])) { throw new Exception('DB Source requires a db-name to be set'); } }
private static function getSqlStatement($manual) { $bulk = array(array(null, Source::get_by_shortName('MDN'), '2007-09-15'), array(null, Source::get_by_shortName('Petro-Sedim'), null), array(null, Source::get_by_shortName('GTA'), null), array(null, Source::get_by_shortName('DCR2'), null), array(null, Source::get_by_shortName('DOR'), null), array(User::get_by_nick('siveco'), null, null), array(User::get_by_nick('RACAI'), null, null)); $conditions = array(); foreach ($bulk as $tuple) { $parts = array(); if ($tuple[0]) { $parts[] = "(userId = {$tuple[0]->id})"; } if ($tuple[1]) { $parts[] = "(sourceId = {$tuple[1]->id})"; } if ($tuple[2]) { $parts[] = "(left(from_unixtime(createDate), 10) = '{$tuple[2]}')"; } $conditions[] = '(' . implode(' and ', $parts) . ')'; } $clause = '(' . implode(' or ', $conditions) . ')'; if ($manual) { $clause = "not {$clause}"; } $statusClause = util_isModerator(PRIV_VIEW_HIDDEN) ? sprintf("status in (%d,%d)", ST_ACTIVE, ST_HIDDEN) : sprintf("status = %d", ST_ACTIVE); $query = "select nick, count(*) as NumDefinitions, sum(length(internalRep)) as NumChars, max(createDate) as Timestamp \n from Definition, User \n where userId = User.id \n and {$statusClause}\n and {$clause} group by nick"; return $query; }
/** * Create Sass source associated with given string * * @param $context Context Context * @param $source string Sass source code * @param $modifiedTime int Last modified time (unix timestamp) * @param $humanName string|null Human-readable description (used for debugging) */ public function __construct(Context $context, $source, $modifiedTime, $humanName = null) { parent::__construct($context); $this->rawSource = $source; $this->rawModifiedTime = $modifiedTime; $this->humanName = $humanName; }
private static function getSqlStatement($manual) { /* * nick source (short) createDate 1:ratio (3-> 33%, 4 -> 25%) */ $bulk = array(array(null, "MDN '00", " = '2007-09-15'", null), array(null, 'Petro-Sedim', null, null), array(null, 'GTA', null, null), array(null, 'DCR2', null, null), array(null, 'DOR', null, null), array('raduborza', 'DOOM 2', " > '2013-01-01'", 4), array(null, 'DRAM', null, null), array('siveco', null, null, null), array('RACAI', null, null, null)); $conditions = array(); foreach ($bulk as $tuple) { $parts = array(); if ($tuple[0]) { $user = User::get_by_nick($tuple[0]); $parts[] = "(userId = {$user->id})"; } if ($tuple[1]) { $src = Source::get_by_shortName($tuple[1]); $parts[] = "(sourceId = {$src->id})"; } if ($tuple[2]) { $parts[] = "(left(from_unixtime(createDate), 10)" . $tuple[2] . ")"; } if ($tuple[3]) { $parts[] = "(Definition.id%{$tuple[3]}!=0)"; } $conditions[] = '(' . implode(' and ', $parts) . ')'; } $clause = '(' . implode(' or ', $conditions) . ')'; if ($manual) { $clause = "not {$clause}"; } $statusClause = util_isModerator(PRIV_VIEW_HIDDEN) ? sprintf("status in (%d,%d)", ST_ACTIVE, ST_HIDDEN) : sprintf("status = %d", ST_ACTIVE); $query = "select nick, count(*) as NumDefinitions, sum(length(internalRep)) as NumChars, max(createDate) as Timestamp \n from Definition, User \n where userId = User.id \n and {$statusClause}\n and {$clause} group by nick"; return $query; }
/** * Convert a tree produced by the tree editor to the format used by loadTree. * We need this in case validation fails and we cannot save the tree, so we need to display it again. **/ static function convertTree($meanings) { $meaningStack = array(); $results = array(); foreach ($meanings as $tuple) { $row = array(); $m = $tuple->id ? self::get_by_id($tuple->id) : Model::factory('Meaning')->create(); $m->internalRep = $tuple->internalRep; $m->htmlRep = AdminStringUtil::htmlize($m->internalRep, 0); $m->internalEtymology = $tuple->internalEtymology; $m->htmlEtymology = AdminStringUtil::htmlize($m->internalEtymology, 0); $m->internalComment = $tuple->internalComment; $m->htmlComment = AdminStringUtil::htmlize($m->internalComment, 0); $row['meaning'] = $m; $row['sources'] = Source::loadByIds(StringUtil::explode(',', $tuple->sourceIds)); $row['tags'] = MeaningTag::loadByIds(StringUtil::explode(',', $tuple->meaningTagIds)); $row['relations'] = Relation::loadRelatedLexems($tuple->relationIds); $row['children'] = array(); if ($tuple->level) { $meaningStack[$tuple->level - 1]['children'][] =& $row; } else { $results[] =& $row; } $meaningStack[$tuple->level] =& $row; unset($row); } return $results; }
public function addDigg($feedId, $uid) { $data["feedid"] = $feedId; $data["uid"] = $uid; $data["uid"] = !$data["uid"] ? Ibos::app()->user->uid : $data["uid"]; if (!$data["uid"]) { $this->addError("addDigg", "未登录不能赞"); return false; } $isExit = $this->getIsExists($feedId, $uid); if ($isExit) { $this->addError("addDigg", "你已经赞过"); return false; } $data["ctime"] = time(); $res = $this->add($data); if ($res) { $feed = Source::getSourceInfo("feed", $feedId); Feed::model()->updateCounters(array("diggcount" => 1), "feedid = " . $feedId); Feed::model()->cleanCache($feedId); $user = User::model()->fetchByUid($uid); $config["{user}"] = $user["realname"]; $config["{sourceContent}"] = StringUtil::filterCleanHtml($feed["source_body"]); $config["{sourceContent}"] = str_replace("◆", "", $config["{sourceContent}"]); $config["{sourceContent}"] = StringUtil::cutStr($config["{sourceContent}"], 34); $config["{url}"] = $feed["source_url"]; $config["{content}"] = Ibos::app()->getController()->renderPartial("application.modules.message.views.remindcontent", array("recentFeeds" => Feed::model()->getRecentFeeds()), true); Notify::model()->sendNotify($feed["uid"], "message_digg", $config); UserUtil::updateCreditByAction("diggweibo", $uid); UserUtil::updateCreditByAction("diggedweibo", $feed["uid"]); } return $res; }
/** * @see Action::execute() */ public function execute() { parent::execute(); $headRevision = $this->source->getHeadRevision(); if ($this->source->revision == $headRevision) { $revision = $headRevision; } else { $revision = '<strong class="red">' . WCF::getLanguage()->getDynamicVariable('pb.source.scm.higherRevisionAvailable', array('source' => $this->source)) . '</strong>'; } $revision = array('revision' => $revision); $json = JSON::encode($revision); // send JSON response header('Content-type: application/json'); echo $json; exit; }
/** * Static function to refresh src_org_cache from src_org * * @param Source|src_id|src_uuid $source * @return int number of rows cached */ public static function refresh_cache($source) { $conn = AIR2_DBManager::get_master_connection(); // get the src_id $src_id; if (is_numeric($source)) { $src_id = $source; } elseif (is_string($source)) { $q = 'select src_id from source where src_uuid = ?'; $src_id = $conn->fetchOne($q, array($source), 0); } elseif (is_object($source)) { $src_id = $source->src_id; } // sanity! if (!$src_id) { Carper::carp("Source !exists"); return; } // delete all src_org_cache recs for this source $conn->execute("delete from src_org_cache where soc_src_id = {$src_id}"); // array of org_id => status $org_status = Source::get_authz_status($src_id); // bulk-insert $vals = array(); foreach ($org_status as $org_id => $status) { $vals[] = "({$src_id},{$org_id},'{$status}')"; } if (count($vals)) { $vals = implode(',', $vals); $stmt = "insert into src_org_cache (soc_src_id, soc_org_id, soc_status)"; $conn->execute("{$stmt} values {$vals}"); } return count($vals); }
public function actionIndex() { $shareInfo["sid"] = intval(EnvUtil::getRequest("sid")); $shareInfo["stable"] = StringUtil::filterCleanHtml(EnvUtil::getRequest("stable")); $shareInfo["initHTML"] = StringUtil::filterDangerTag(EnvUtil::getRequest("initHTML")); $shareInfo["curid"] = StringUtil::filterCleanHtml(EnvUtil::getRequest("curid")); $shareInfo["curtable"] = StringUtil::filterCleanHtml(EnvUtil::getRequest("curtable")); $shareInfo["module"] = StringUtil::filterCleanHtml(EnvUtil::getRequest("module")); $shareInfo["isrepost"] = intval(EnvUtil::getRequest("isrepost")); if (empty($shareInfo["stable"]) || empty($shareInfo["sid"])) { echo "类型和资源ID不能为空"; exit; } if (!($oldInfo = Source::getSourceInfo($shareInfo["stable"], $shareInfo["sid"], false, $shareInfo["module"]))) { echo "此信息不可以被转发"; exit; } empty($shareInfo["module"]) && ($shareInfo["module"] = $oldInfo["module"]); if (empty($shareInfo["initHTML"]) && !empty($shareInfo["curid"])) { if ($shareInfo["curid"] != $shareInfo["sid"] && $shareInfo["isrepost"] == 1) { $curInfo = Source::getSourceInfo($shareInfo["curtable"], $shareInfo["curid"], false, "weibo"); $userInfo = $curInfo["source_user_info"]; $shareInfo["initHTML"] = " //@" . $userInfo["realname"] . ":" . $curInfo["source_content"]; $shareInfo["initHTML"] = str_replace(array("\n", "\r"), array("", ""), $shareInfo["initHTML"]); } } $shareInfo["shareHtml"] = !empty($oldInfo["shareHtml"]) ? $oldInfo["shareHtml"] : ""; $data = array("shareInfo" => $shareInfo, "oldInfo" => $oldInfo); $this->renderPartial("index", $data); }
/** * @see Action::execute() */ public function execute() { // call execute event parent::execute(); if ($this->source->enableCheckout && $this->checkoutRepository) { // load scm driver $className = ucfirst(Source::validateSCM($this->source->scm)); // check out repository require_once WCF_DIR . 'lib/system/scm/' . $className . '.class.php'; call_user_func(array($className, 'checkout'), $this->source->url, $this->source->sourceDirectory, array('username' => $this->source->username, 'password' => $this->source->password)); // set revision $revision = $this->source->getHeadRevision(); $this->source->update(null, null, null, null, null, null, null, $revision); } // rebuild package data if requested if ($this->rebuildPackageData) { require_once PB_DIR . 'lib/system/package/PackageHelper.class.php'; PackageHelper::readPackages($this->source); } // call executed event $this->executed(); // forward HeaderUtil::redirect('index.php?page=SourceView&sourceID=' . $this->source->sourceID . SID_ARG_2ND_NOT_ENCODED); exit; }
public function _make_linguistic_object($fieldsAndValues) { $logger = Logger::getLogger('LinguisticObjects.makeLinguisticObject'); $logger->debug("\$fieldsAndValues= " . print_r($fieldsAndValues, TRUE)); $type = $fieldsAndValues['type']; $logger->debug("type= {$type}"); $obj = NULL; if ($type == 'n' || $type == 'a' || $type == 'e' || $type == 'c') { $obj = new NounRoot($fieldsAndValues); array_push(self::$rootIDs, $obj->id()); } elseif ($type == 'v') { $obj = new VerbRoot($fieldsAndValues); array_push(self::$rootIDs, $obj->id()); } elseif ($type == 's') { $obj = new Source($fieldsAndValues); array_push(self::$sourceIDs, $obj->id()); } elseif ($type == 'sn' || $type == 'sv' || $type == 'q') { $obj = new Suffix($fieldsAndValues); array_push(self::$affixIDs, $obj->id()); } elseif ($type == 'tn') { $obj = new NounEnding($fieldsAndValues); array_push(self::$affixIDs, $obj->id()); } elseif ($type == 'tv') { $obj = new VerbEnding($fieldsAndValues); array_push(self::$affixIDs, $obj->id()); } elseif ($type == 'vw') { $obj = new VerbWord($fieldsAndValues); self::$verbWords[$object->getVerb()] = $obj; } elseif ($type == 'pr') { $obj = new Pronoun($fieldsAndValues); array_push(self::$rootIDs, $obj->id()); } elseif ($type == 'pd' || $type == 'ad') { $obj = new Demonstrative($fieldsAndValues); array_push(self::$rootIDs, $obj->id()); $roots = explode(' ', $obj->get_root()); foreach ($roots as $a_root) { $newFieldsAndValues = $fieldsAndValues; $newFieldsAndValues['morpheme'] = $a_root; $newFieldsAndValues['root'] = $a_root; $new_obj = new Demonstrative($newFieldsAndValues); array_push(self::$rootIDs, $new_obj->id()); } } else { $logger->debug("type '{$type}' not supported yet"); } return $obj; }
static function &getInstance($data, $simple = true) { global $gedcom_record_cache, $GEDCOM, $pgv_changes; if (is_array($data)) { $ged_id = $data['ged_id']; $pid = $data['xref']; } else { $ged_id = get_id_from_gedcom($GEDCOM); $pid = $data; } // Check the cache first if (isset($gedcom_record_cache[$pid][$ged_id])) { return $gedcom_record_cache[$pid][$ged_id]; } // Look for the record in the database if (!is_array($data)) { $data = fetch_source_record($pid, $ged_id); // If we didn't find the record in the database, it may be remote if (!$data && strpos($pid, ':')) { list($servid, $remoteid) = explode(':', $pid); $service = ServiceClient::getInstance($servid); if ($service) { // TYPE will be replaced with the type from the remote record $data = $service->mergeGedcomRecord($remoteid, "0 @{$pid}@ TYPE\n1 RFN {$pid}", false); } } // If we didn't find the record in the database, it may be new/pending if (!$data && PGV_USER_CAN_EDIT && isset($pgv_changes[$pid . '_' . $GEDCOM])) { $data = find_updated_record($pid); $fromfile = true; } // If we still didn't find it, it doesn't exist if (!$data) { return null; } } // Create the object $object = new Source($data, $simple); if (!empty($fromfile)) { $object->setChanged(true); } // Store it in the cache $gedcom_record_cache[$object->xref][$object->ged_id] =& $object; //-- also store it using its reference id (sid:pid and local gedcom for remote links) $gedcom_record_cache[$pid][$ged_id] =& $object; return $object; }
public function source() { $result = Source::make()->type(Source::SOURCE_SQL)->length(\Input::get('length') ? \Input::get('length') : $this->display_length)->start(\Input::get('start') ? \Input::get('start') : $this->display_start)->search(\Input::get('search') ? \Input::get('search') : '')->order(\Input::get('order') ? \Input::get('order') : '')->rowssql($this->rows_source_sql)->countsql($this->count_filtered_records_sql)->totalsql($this->count_total_records_sql)->fields(explode(',', $this->fields['fields']))->searchables(explode(',', $this->fields['searchables']))->orderables($this->fields['orderables'])->cells($this->cells())->custom_filters($this->filters); if (\Input::get('columns')) { $result->columns(\Input::get('columns')); } return $result; }
public function testSave() { Stripe::setApiKey('sk_test_JieJALRz7rPz7boV17oMma7a'); $s = Source::create(array('type' => 'bitcoin', 'currency' => 'usd', 'amount' => '100', 'owner[email]' => '*****@*****.**')); $this->assertSame('bitcoin', $s->type); $source = Source::retrieve($s->id); $this->assertSame(100, $source->amount); }
/** * @expectedException \Magento\Framework\View\Asset\File\NotFoundException * @expectedExceptionMessage Unable to get content for 'Magento_Module/dir/file.css' */ public function testGetContentNotFound() { $this->source->expects($this->once()) ->method('getContent') ->with($this->object) ->will($this->returnValue(false)); $this->object->getContent(); }
/** * {@inheritdoc} */ public function getContent() { $content = $this->source->getContent($this); if (false === $content) { throw new File\NotFoundException("Unable to get content for '{$this->getPath()}'"); } return $content; }
/** * @see Action::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_POST['directory'])) { $this->directory = StringUtil::trim($_POST['directory']); } if (isset($_POST['packageName'])) { $this->packageName = StringUtil::trim($_POST['packageName']); } if (isset($_POST['sourceID'])) { $this->sourceID = intval($_POST['sourceID']); } $this->source = new Source($this->sourceID); if (!$this->source->sourceID || !$this->source->hasAccess()) { throw new IllegalLinkException(); } }
function getImages(&$img, $eid = -1, $sid = -1) { global $tblprefix, $err_images; $iquery = "SELECT image_id, i.title, p.person_id as p_person_id, i.event_id, " . Event::getFields("e") . "," . PersonDetail::getFields() . "," . Source::getFields("s") . ", s.source_id as s_source_id" . " FROM " . $tblprefix . "images i " . " LEFT JOIN " . $tblprefix . "event e ON e.event_id = i.event_id " . " LEFT JOIN " . $tblprefix . "people p ON p.person_id = e.person_id " . " LEFT JOIN " . $tblprefix . "source s ON s.source_id = i.source_id " . PersonDetail::getJoins(); switch ($img->queryType) { case Q_RANDOM: $iquery .= $this->addPersonRestriction(" WHERE ") . $this->addRandom(); break; default: if ($sid > 0) { $iquery .= " WHERE s.source_id = " . quote_smart($sid); } else { if ($eid > 0) { $iquery .= " WHERE e.event_id = " . quote_smart($eid); } else { if (isset($img->person->person_id)) { $iquery .= " WHERE "; $iquery .= "p.person_id = " . quote_smart($img->person->person_id); $iquery .= $this->addPersonRestriction(" AND "); if (isset($img->image_id)) { $iquery .= " AND image_id=" . $img->image_id; } $iquery .= " ORDER BY e.date1"; } else { $bool = " WHERE "; if (isset($img->image_id)) { $iquery .= " WHERE image_id=" . $img->image_id; $bool = " AND "; } $iquery .= $this->addPersonRestriction($bool) . " ORDER BY b.date1"; } } } break; } $this->addLimit($img, $query); $iresult = $this->runQuery($iquery, $err_images); $res = array(); $img->numResults = 0; while ($row = $this->getNextRow($iresult)) { $image = new Image(); $image->person = new PersonDetail(); $image->person->loadFields($row, L_HEADER, "p_"); $image->person->name->loadFields($row, "n_"); $image->image_id = $row["image_id"]; $image->title = $row["title"]; $image->event = new Event(); $image->event->loadFields($row, "e_"); $image->source = new Source(); $image->source->loadFields($row, "s_"); $image->description = $image->event->descrip; $image->date = $image->event->date1; $res[] = $image; $img->numResults++; } $this->freeResultSet($iresult); $img->results = $res; }