protected function getPathArgumentForLinterFuture($path)
 {
     $full_path = Filesystem::resolvePath($path);
     $ret = array($full_path);
     // The |path| we get fed needs to be made relative to the project_root,
     // otherwise the |engine| won't recognise it.
     $relative_path = Filesystem::readablePath($full_path, $this->getProjectRoot());
     $changed = $this->getEngine()->getPathChangedLines($relative_path);
     if ($changed !== null) {
         // Convert the ordered set of changed lines to a list of ranges.
         $changed_lines = array_keys(array_filter($changed));
         $ranges = array(array($changed_lines[0], $changed_lines[0]));
         foreach (array_slice($changed_lines, 1) as $line) {
             $range = last($ranges);
             if ($range[1] + 1 === $line) {
                 ++$range[1];
                 $ranges[last_key($ranges)] = $range;
             } else {
                 $ranges[] = array($line, $line);
             }
         }
         foreach ($ranges as $range) {
             $ret[] = sprintf('--lines=%d:%d', $range[0], $range[1]);
         }
     }
     return csprintf('%Ls', $ret);
 }
 /**
  *
  * @param String $file
  * @throws \Exception
  */
 public function __construct($file)
 {
     $this->_position = 0;
     if (is_array($file) && strlen(rtrim($file[0], chr(10) . chr(13) . "\n" . "\r")) == 400) {
         $this->file = $file;
     } else {
         if (is_file($file) && file_exists($file)) {
             $this->file = file($file);
         } else {
             if (is_string($file)) {
                 $this->file = preg_split('/\\r\\n|\\r|\\n/', $file);
                 if (empty(last($this->file))) {
                     array_pop($this->file);
                 }
             } else {
                 throw new \Exception("Arquivo: não existe");
             }
         }
     }
     $this->isRetorno = substr($this->file[0], 0, 9) == '02RETORNO' ? true : false;
     if (!in_array(substr($this->file[0], 76, 3), array_keys($this->bancos))) {
         throw new \Exception(sprintf("Banco: %s, inválido", substr($this->file[0], 76, 3)));
     }
     $this->header = new Header();
     $this->trailer = new Trailer();
 }
 protected function validateTransaction(PhabricatorLiskDAO $object, $type, array $xactions)
 {
     $errors = parent::validateTransaction($object, $type, $xactions);
     switch ($type) {
         case PhabricatorMetaMTAApplicationEmailTransaction::TYPE_ADDRESS:
             foreach ($xactions as $xaction) {
                 $email = $xaction->getNewValue();
                 if (!strlen($email)) {
                     // We'll deal with this below.
                     continue;
                 }
                 if (!PhabricatorUserEmail::isValidAddress($email)) {
                     $errors[] = new PhabricatorApplicationTransactionValidationError($type, pht('Invalid'), pht('Email address is not formatted properly.'));
                 }
             }
             $missing = $this->validateIsEmptyTextField($object->getAddress(), $xactions);
             if ($missing) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('You must provide an email address.'), nonempty(last($xactions), null));
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             }
             break;
     }
     return $errors;
 }
 public function run()
 {
     $faker = Faker::create();
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->password_confirmation = 'superadmin';
     $user->confirmed = 1;
     $user->profile_photo = $faker->imageUrl($width = 198, $height = 198);
     $fullname = explode(" ", $faker->name);
     $surname = last($fullname);
     unset($fullname[count($fullname) - 1]);
     $name = implode(" ", $fullname);
     $user->name = $name;
     $user->surname = $surname;
     $user->save();
     $user = new User();
     $user->username = '******';
     $user->email = '*****@*****.**';
     $user->password = '******';
     $user->password_confirmation = 'admin';
     $user->confirmed = 1;
     $user->profile_photo = $faker->imageUrl($width = 198, $height = 198);
     $fullname = explode(" ", $faker->name);
     $surname = last($fullname);
     unset($fullname[count($fullname) - 1]);
     $name = implode(" ", $fullname);
     $user->name = $name;
     $user->surname = $surname;
     $user->save();
 }
 protected function curl_run($comicId, $onlineId)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->comic_url . $onlineId . "/");
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $output = curl_exec($ch);
     $matchArr = [];
     //$output = '<a href="http://8yyls.com/20579">第154話</a>' . '<a href="http://8yyls.com/20375">第004卷</a>';
     preg_match_all("/http:\\/\\/8yyls\\.com\\/[0-9]+[\\/]?\">第[0-9]+(卷|話)/", $output, $matchArr, PREG_OFFSET_CAPTURE);
     $maxNum = last($matchArr[0]);
     $result = [];
     $result = explode('">第', $maxNum[0]);
     $book = \App\Books::where('comics_id', $comicId)->first();
     if ($book === null) {
         $book = new \App\Books();
         $book->comics_id = $comicId;
         $book->link = $result[0];
         $book->chapter = substr($result[1], 0, 3);
         $book->is_read = false;
         $book->save();
     } else {
         if ($book->chapter !== substr($result[1], 0, 3)) {
             $book->link = $result[0];
             $book->chapter = substr($result[1], 0, 3);
             $book->is_read = false;
             $book->save();
         }
     }
     /** finished curl not test */
     curl_close($ch);
 }
Example #6
0
 protected function validateTransaction(PhabricatorLiskDAO $object, $type, array $xactions)
 {
     $errors = parent::validateTransaction($object, $type, $xactions);
     switch ($type) {
         case PhamePostTransaction::TYPE_TITLE:
             $missing = $this->validateIsEmptyTextField($object->getTitle(), $xactions);
             if ($missing) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('Title is required.'), nonempty(last($xactions), null));
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             }
             break;
         case PhamePostTransaction::TYPE_BLOG:
             if ($this->getIsNewObject()) {
                 if (!$xactions) {
                     $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('When creating a post, you must specify which blog it ' . 'should belong to.'), null);
                     $error->setIsMissingFieldError(true);
                     $errors[] = $error;
                     break;
                 }
             }
             foreach ($xactions as $xaction) {
                 $new_phid = $xaction->getNewValue();
                 $blog = id(new PhameBlogQuery())->setViewer($this->getActor())->withPHIDs(array($new_phid))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
                 if ($blog) {
                     continue;
                 }
                 $errors[] = new PhabricatorApplicationTransactionValidationError($type, pht('Invalid'), pht('The specified blog PHID ("%s") is not valid. You can only ' . 'create a post on (or move a post into) a blog which you ' . 'have permission to see and edit.', $new_phid), $xaction);
             }
             break;
     }
     return $errors;
 }
 protected function validateTransaction(PhabricatorLiskDAO $object, $type, array $xactions)
 {
     $errors = parent::validateTransaction($object, $type, $xactions);
     switch ($type) {
         case PhortuneAccountTransaction::TYPE_NAME:
             $missing = $this->validateIsEmptyTextField($object->getName(), $xactions);
             if ($missing) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('Account name is required.'), nonempty(last($xactions), null));
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             }
             break;
         case PhabricatorTransactions::TYPE_EDGE:
             foreach ($xactions as $xaction) {
                 switch ($xaction->getMetadataValue('edge:type')) {
                     case PhortuneAccountHasMemberEdgeType::EDGECONST:
                         // TODO: This is a bit cumbersome, but validation happens before
                         // transaction normalization. Maybe provide a cleaner attack on
                         // this eventually? There's no way to generate "+" or "-"
                         // transactions right now.
                         $new = $xaction->getNewValue();
                         $set = idx($new, '=', array());
                         if (empty($set[$this->requireActor()->getPHID()])) {
                             $error = new PhabricatorApplicationTransactionValidationError($type, pht('Invalid'), pht('You can not remove yourself as an account member.'), $xaction);
                             $errors[] = $error;
                         }
                         break;
                 }
             }
             break;
     }
     return $errors;
 }
 protected function renderObjectEmbed($object, $handle, $options)
 {
     $embed_paste = id(new PasteEmbedView())->setPaste($object)->setHandle($handle);
     if (strlen($options)) {
         $parser = new PhutilSimpleOptions();
         $opts = $parser->parse(substr($options, 1));
         foreach ($opts as $key => $value) {
             if ($key == 'lines') {
                 $embed_paste->setLines(preg_replace('/[^0-9]/', '', $value));
             } else {
                 if ($key == 'highlight') {
                     $highlights = preg_split('/,|&/', preg_replace('/\\s+/', '', $value));
                     $to_highlight = array();
                     foreach ($highlights as $highlight) {
                         $highlight = explode('-', $highlight);
                         if (!empty($highlight)) {
                             sort($highlight);
                             $to_highlight = array_merge($to_highlight, range(head($highlight), last($highlight)));
                         }
                     }
                     $embed_paste->setHighlights(array_unique($to_highlight));
                 }
             }
         }
     }
     return $embed_paste;
 }
Example #9
0
 public function run()
 {
     DB::table('categories')->delete();
     $jsonCat = json_decode(file_get_contents(url('/categories.json')));
     foreach ($jsonCat as $categoriesParent) {
         $cat = new Category();
         $cat->title = $categoriesParent->title;
         $cat->slug = last(explode('/', $categoriesParent->slug));
         $cat->save();
         foreach ($categoriesParent->children as $catChild1) {
             $cat1 = new Category();
             $cat1->title = $catChild1->title;
             $cat1->slug = last(explode('/', $catChild1->slug));
             $cat1->parent_id = $cat->id;
             $cat1->save();
             foreach ($catChild1->children as $catChild2) {
                 $cat2 = new Category();
                 $cat2->title = $catChild2->title;
                 $cat2->slug = last(explode('/', $catChild2->slug));
                 $cat2->parent_id = $cat1->id;
                 $cat2->save();
             }
         }
     }
 }
Example #10
0
 /**
  * Display the specified 3-week calendar.
  *
  * @param  int  $date
  * @return \Illuminate\Http\Response
  */
 public function show($date)
 {
     $datelist = $this->getDateList($date);
     $visits = Visit::with('place')->where('date', '>=', head($datelist))->where('date', '<=', last($datelist))->get();
     $visits = $visits->keyBy('date');
     return view('calendar.index', compact('visits', 'datelist'));
 }
Example #11
0
 public function links()
 {
     $params = [];
     $list = [];
     $extras = [];
     $new_list_length = null;
     if (is_array(last($this->route_params))) {
         $extras = array_pop($this->route_params);
     }
     $append_plain = $this->getPlainTextExtras($extras, 'append_plain', $this->items);
     $prepend_plain = $this->getPlainTextExtras($extras, 'prepend_plain', $this->items);
     foreach ($this->route_params as $param) {
         $params[] = $this->collectKeys($this->items, $param)->toArray();
     }
     $items = $this->collectKeys($this->items, $this->key);
     if (array_key_exists('truncate', $extras)) {
         $this->setCharLimit($extras['truncate']);
         $new_list_length = $this->getTruncatedList($items);
         $this->setCharLimit(null);
     }
     foreach ($items as $key => $item) {
         $str = '';
         if ($str_prepend = $this->getPlainTextReplaced($extras, 'prepend_plain', $prepend_plain, $key)) {
             $str .= $str_prepend;
         }
         $str .= '<a href="' . route($this->route, array_fetch($params, $key)) . '">';
         $str .= $item . '</a>';
         if ($str_append = $this->getPlainTextReplaced($extras, 'append_plain', $append_plain, $key)) {
             $str .= $str_append;
         }
         $list[] = $str;
     }
     return $this->listize($list, $new_list_length);
 }
Example #12
0
 public function postUpload($relation_id, $ref_id)
 {
     //
     $file = Input::file('imagem');
     //
     $validator = Validator::make(['imagem' => $file], ['imagem' => 'required|mimes:jpeg,bmp,png|max:5000']);
     if ($validator->fails()) {
         $errors = $validator->errors();
         return response()->json(['error' => true, 'message' => $errors->first('file_image')]);
     }
     //
     $this->destroy($relation_id, $ref_id);
     //
     $img = Image::make($file);
     //
     $image = new ImageModel();
     $image->position = 0;
     $image->ref_id = $ref_id;
     $image->relation_id = $relation_id;
     $image->type = last(explode('/', $img->mime()));
     $image->save();
     //
     $img->save($image->getPath());
     //
     return response()->json(['error' => false, 'message' => 'Imagem enviada com sucesso!']);
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer(['front.header', 'admin.header'], function ($view) {
         $languages = [];
         $folders = File::directories(base_path('resources/lang/'));
         foreach ($folders as $folder) {
             $languages[] = str_replace('\\', '', last(explode('/', $folder)));
         }
         $view->with('languages', $languages);
     });
     view()->composer('front.header', function ($view) {
         $apps = Application::all();
         $view->with('apps', $apps);
     });
     view()->composer('admin.news.form', function ($view) {
         $categories = ['update' => trans('news.category.update'), 'maintenance' => trans('news.category.maintenance'), 'event' => trans('news.category.event'), 'contest' => trans('news.category.contest'), 'other' => trans('news.category.other')];
         $view->with('categories', $categories);
     });
     view()->composer('front.widgets', function ($view) {
         $client_status = @fsockopen(settings('server_ip', '127.0.0.1'), 6543, $errCode, $errStr, 1) ? TRUE : FALSE;
         $worlds = DB::connection('account')->table('worlds')->get();
         $view->with('client_status', $client_status)->with('worlds', $worlds);
     });
     view()->composer('admin.donate.settings', function ($view) {
         $view->with('currencies', trans('donate.currency'));
     });
 }
 public function peekWorkingDirectory()
 {
     if ($this->workingDirectoryStack) {
         return last($this->workingDirectoryStack);
     }
     return null;
 }
 public function newBranchFromCommit(PhabricatorRepositoryCommit $cut_point, $branch_date, $symbolic_name = null)
 {
     $template = $this->releephProject->getDetail('branchTemplate');
     if (!$template) {
         $template = ReleephBranchTemplate::getRequiredDefaultTemplate();
     }
     $cut_point_handle = id(new PhabricatorHandleQuery())->setViewer($this->requireActor())->withPHIDs(array($cut_point->getPHID()))->executeOne();
     list($name, $errors) = id(new ReleephBranchTemplate())->setCommitHandle($cut_point_handle)->setBranchDate($branch_date)->setReleephProjectName($this->releephProject->getName())->interpolate($template);
     $basename = last(explode('/', $name));
     $table = id(new ReleephBranch());
     $transaction = $table->openTransaction();
     $branch = id(new ReleephBranch())->setName($name)->setBasename($basename)->setReleephProjectID($this->releephProject->getID())->setCreatedByUserPHID($this->requireActor()->getPHID())->setCutPointCommitPHID($cut_point->getPHID())->setIsActive(1)->setDetail('branchDate', $branch_date)->save();
     /**
      * Steal the symbolic name from any other branch that has it (in this
      * project).
      */
     if ($symbolic_name) {
         $others = id(new ReleephBranch())->loadAllWhere('releephProjectID = %d', $this->releephProject->getID());
         foreach ($others as $other) {
             if ($other->getSymbolicName() == $symbolic_name) {
                 $other->setSymbolicName(null)->save();
             }
         }
         $branch->setSymbolicName($symbolic_name)->save();
     }
     $table->saveTransaction();
     return $branch;
 }
Example #16
0
function parse_template($string)
{
    # Don't mess with the $stack/$tem assignments!  Since
    # PHP references point to the variable, not the data,
    # it really does have to be written exactly like this.
    $stack[] = array();
    $tem =& last($stack);
    # note: for some reason this captures '<!--' but not '-->'.
    $pieces = preg_split("/(<!--)?(~[^~]*~)(?(1)-->)/", $string, -1, PREG_SPLIT_DELIM_CAPTURE);
    foreach ($pieces as $piece) {
        if ($piece[0] == '~') {
            $tag = preg_replace('/~([^?.]*)[?.]?~/', "\$1", $piece);
            $last = substr($piece, -2, 1);
            if ($last == '?') {
                $stack[] = array($tag);
                $tem[] =& last($stack);
                $tem =& last($stack);
            } elseif ($last == '.') {
                $cur = $stack[count($stack) - 1][0];
                if ($tag && $tag != $cur) {
                    die("Invalid template: tried to close '{$tag}', but '{$cur}' is current.");
                }
                array_pop($stack);
                $tem =& last($stack);
            } else {
                $tem[] = array($tag);
            }
        } elseif ($piece and $piece != '<!--') {
            $tem[] = $piece;
        }
    }
    return $tem;
}
Example #17
0
 static function wrap($name, $exps)
 {
     if ($exps->is_empty() || last($exps->expressions)->jumps()) {
         return $exps;
     }
     return $exps->push(yy('Call', yy('Value', yy('Literal', $name), array(yy('Access', yy('Literal', 'push')))), array($exps->pop())));
 }
Example #18
0
 protected function mergePriority($route)
 {
     $row = last($this->groupStack);
     if (isset($row['priority'])) {
         $route->setPriority($row['priority']);
     }
 }
Example #19
0
 /**
  * Load the namespace which prevents use of an Almanac name, if one exists.
  */
 public static function loadRestrictedNamespace(PhabricatorUser $viewer, $name)
 {
     // For a name like "x.y.z", produce a list of controlling namespaces like
     // ("z", "y.x", "x.y.z").
     $names = array();
     $parts = explode('.', $name);
     for ($ii = 0; $ii < count($parts); $ii++) {
         $names[] = implode('.', array_slice($parts, -($ii + 1)));
     }
     // Load all the possible controlling namespaces.
     $namespaces = id(new AlmanacNamespaceQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withNames($names)->execute();
     if (!$namespaces) {
         return null;
     }
     // Find the "nearest" (longest) namespace that exists. If both
     // "sub.domain.com" and "domain.com" exist, we only care about the policy
     // on the former.
     $namespaces = msort($namespaces, 'getNameLength');
     $namespace = last($namespaces);
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $namespace, PhabricatorPolicyCapability::CAN_EDIT);
     if ($can_edit) {
         return null;
     }
     return $namespace;
 }
 public function testLists()
 {
     $lists = Post::where('views', '>=', 10)->lists('id', 'title');
     $debug = last(DB::getQueryLog());
     $this->assertEquals(['Bar' => 2, 'FooBar' => 3], $lists);
     $this->assertEquals('select "id", "title" from "posts" where "published" = ? and "views" >= ? and "status" = ?', $debug['query']);
 }
 /**
  * Redirect back
  *
  * @param int $id
  * @return \Illuminate\Http\RedirectResponse
  */
 protected function readRedirect($topicType, $id)
 {
     $topic = $this->topicRepo->requireById($id);
     $forum = $this->forumRepo->requireById(last($topic->pathExplode()));
     return Redirect::route('forums.show', ['id' => $forum->id, 'slug' => $forum->slug]);
     return Redirect::to('/');
 }
Example #22
0
 protected function setCommonVariable()
 {
     // Achieve that segment
     $this->accessUrl = config('cmsharenjoy.access_url');
     // Get the action name
     $routeArray = Str::parseCallback(Route::currentRouteAction(), null);
     if (last($routeArray) != null) {
         // Remove 'controller' from the controller name.
         $controller = str_replace('Controller', '', class_basename(head($routeArray)));
         // Take out the method from the action.
         $action = str_replace(['get', 'post', 'patch', 'put', 'delete'], '', last($routeArray));
         // post, report
         $this->onController = strtolower($controller);
         session()->put('onController', $this->onController);
         view()->share('onController', $this->onController);
         // get-create, post-create
         $this->onMethod = Str::slug(Request::method() . '-' . $action);
         session()->put('onMethod', $this->onMethod);
         view()->share('onMethod', $this->onMethod);
         // create, update
         $this->onAction = strtolower($action);
         session()->put('onAction', $this->onAction);
         view()->share('onAction', $this->onAction);
     }
     // Brand name from setting
     $this->brandName = Setting::get('brand_name');
     // Share some variables to views
     view()->share('brandName', $this->brandName);
     view()->share('langLocales', config('cmsharenjoy.locales'));
     view()->share('activeLanguage', session('sharenjoy.backEndLanguage'));
     // Set the theme
     // $this->theme = Theme::uses('front');
     // Message
     view()->share('messages', Message::getMessageBag());
 }
Example #23
0
 /**
  * @inheritdoc
  */
 public function getRandomIdsForLastEntity($uri, $payload, $idPlaceholder = '{random_id}')
 {
     $take = substr_count($payload, $idPlaceholder);
     $entities = $this->uriParser->entities($uri);
     $table = last($entities);
     return $this->idRetriever->getRandomIdsFromTable($table, $take);
 }
Example #24
0
 /**
  * Do the stats!
  */
 public function calculateStats()
 {
     $classes = $this->getClasses();
     $dates = $this->getDates();
     //explore all class to stated
     foreach ($classes as $objectClass => $constraints) {
         //prepare useful data
         $stats_fields = [];
         $objectName = last(explode('\\', $objectClass));
         //explore each date to count from
         foreach ($dates as $dateName => $date) {
             //create the sql request
             $sql = $objectClass::where('created_at', '>=', $date->toDateTimeString());
             //taking into account the constraint
             foreach ($constraints as $constraintName => $constraintValue) {
                 $sql = $sql->where($constraintName, $constraintValue);
             }
             //count !
             $count = $sql->count();
             //set count
             $stats_fields[] = ["since" => $dateName, "value" => $count];
         }
         //add to stats array
         $this->stats[] = ['name' => $objectName, 'values' => $stats_fields];
     }
 }
Example #25
0
 /**
  * Build the Site Map
  */
 protected function buildSiteMap()
 {
     $postsInfo = $this->getPostsInfo();
     $dates = array_values($postsInfo);
     sort($dates);
     $lastmod = last($dates);
     $url = trim(url(), '/') . '/';
     $xml = [];
     $xml[] = '<?xml version="1.0" encoding="UTF-8"?' . '>';
     $xml[] = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     $xml[] = '  <url>';
     $xml[] = "    <loc>{$url}</loc>";
     $xml[] = "    <lastmod>{$lastmod}</lastmod>";
     $xml[] = '    <changefreq>daily</changefreq>';
     $xml[] = '    <priority>0.8</priority>';
     $xml[] = '  </url>';
     foreach ($postsInfo as $slug => $lastmod) {
         $xml[] = '  <url>';
         $xml[] = "    <loc>{$url}home/{$slug}</loc>";
         $xml[] = "    <lastmod>{$lastmod}</lastmod>";
         $xml[] = "  </url>";
     }
     $xml[] = '</urlset>';
     return join("\n", $xml);
 }
Example #26
0
 public function registerMetaAttributes($shortCut, $classname)
 {
     if (last(array_values(class_parents($classname))) !== MetaAttributes::class) {
         throw new \InvalidArgumentException('Meta attribute but be extended from ' . MetaAttributes::class . '. ' . $classname . ' was given.');
     }
     $this->metas[$shortCut] = $classname;
 }
Example #27
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Model::unguard();
     // DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // \App\Provinsi::truncate();
     // DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // \App\Kabupaten::truncate();
     // DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // \App\Kecamatan::truncate();
     // DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     \App\Kelurahan::truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     $this->call(ProvinsiPart1Seeder::class);
     $classes = (require base_path() . '/vendor/composer/autoload_classmap.php');
     foreach ($classes as $class) {
         //if(strpos($class, 'Seeder') !== false && strpos($class, 'Kelurahan') == true)
         if (strpos($class, 'Seeder') !== false && strpos($class, 'DatabaseSeeder') != true && strpos($class, 'ProvinsiPart1Seeder') != true) {
             $seederClass = substr(last(explode('/', $class)), 0, -4);
             //var_dump($seederClass);
             $this->call($seederClass);
         }
     }
     //Model::reguard();
 }
 public function execute(PhutilArgumentParser $args)
 {
     $viewer = $this->getViewer();
     $argv = $args->getArg('argv');
     if (count($argv) !== 2) {
         throw new PhutilArgumentUsageException(pht('Specify a commit and a revision to attach it to.'));
     }
     $commit_name = head($argv);
     $revision_name = last($argv);
     $commit = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(array($commit_name))->executeOne();
     if (!$commit) {
         throw new PhutilArgumentUsageException(pht('Commit "%s" does not exist.', $commit_name));
     }
     $revision = id(new PhabricatorObjectQuery())->setViewer($viewer)->withNames(array($revision_name))->executeOne();
     if (!$revision) {
         throw new PhutilArgumentUsageException(pht('Revision "%s" does not exist.', $revision_name));
     }
     if (!$revision instanceof DifferentialRevision) {
         throw new PhutilArgumentUsageException(pht('Object "%s" must be a Differential revision.', $revision_name));
     }
     // Reload the revision to get the active diff.
     $revision = id(new DifferentialRevisionQuery())->setViewer($viewer)->withIDs(array($revision->getID()))->needActiveDiffs(true)->executeOne();
     $differential_phid = id(new PhabricatorDifferentialApplication())->getPHID();
     $extraction_engine = id(new DifferentialDiffExtractionEngine())->setViewer($viewer)->setAuthorPHID($differential_phid);
     $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_CONSOLE, array());
     $extraction_engine->updateRevisionWithCommit($revision, $commit, array(), $content_source);
     echo tsprintf("%s\n", pht('Attached "%s" to "%s".', $commit->getMonogram(), $revision->getMonogram()));
 }
Example #29
0
 /**
  * @return string
  */
 public function buildSiteMap()
 {
     // we get all site pages
     $site_pages = $this->getSitePages();
     // we only take the last mod column from the site pages
     $dates = array_column($site_pages, 'last_mod');
     // we sort it
     sort($dates);
     // we get the website last modification date
     $lastmod = last($dates);
     // we get the base url from the website
     $url = route('home');
     $xml = [];
     $xml[] = '<?xml version="1.0" encoding="UTF-8"?' . '>';
     $xml[] = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     $xml[] = '  <url>';
     $xml[] = "    <loc>{$url}</loc>";
     $xml[] = "    <lastmod>{$lastmod}</lastmod>";
     $xml[] = '    <changefreq>daily</changefreq>';
     $xml[] = '    <priority>0.8</priority>';
     $xml[] = '  </url>';
     foreach ($site_pages as $page) {
         $xml[] = "  <url>";
         $xml[] = "    <loc>{$page['url']}</loc>";
         $xml[] = "    <lastmod>{$page['last_mod']}</lastmod>";
         $xml[] = "  </url>";
     }
     $xml[] = '</urlset>';
     return join("\n", $xml);
 }
 protected function validateTransaction(PhabricatorLiskDAO $object, $type, array $xactions)
 {
     $errors = parent::validateTransaction($object, $type, $xactions);
     switch ($type) {
         case PhabricatorCountdownTransaction::TYPE_TITLE:
             $missing = $this->validateIsEmptyTextField($object->getTitle(), $xactions);
             if ($missing) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('You must give the countdown a name.'), nonempty(last($xactions), null));
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             }
             break;
         case PhabricatorCountdownTransaction::TYPE_EPOCH:
             if (!$object->getEpoch() && !$xactions) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('You must give the countdown an end date.'), null);
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             }
             foreach ($xactions as $xaction) {
                 $value = $xaction->getNewValue();
                 if (!$value->isValid()) {
                     $error = new PhabricatorApplicationTransactionValidationError($type, pht('Invalid'), pht('You must give the countdown a valid end date.'), $xaction);
                     $errors[] = $error;
                 }
             }
             break;
     }
     return $errors;
 }