Example #1
0
 /**
  * 删除
  */
 public function actionDelete($id)
 {
     $id = (int) $id;
     $Links = new Links();
     $Links->delete(array('lid' => $id));
     $this->Common->exportResult(true, '成功!');
 }
Example #2
0
 public function deleteLinkAction(Users $user, Links $link)
 {
     if ($this->request->isPost()) {
         $link->delete();
         return $this->redirectByRoute(['for' => 'users.showLinks', 'user' => $user->id]);
     }
 }
 function get_link_categories()
 {
     $Links = new Links();
     $conditon = array('user_id' => $_SESSION['user']['id'], 'is_active' => 1);
     $link_categories_array = $Links->load_category($conditon);
     return $link_categories_array;
 }
Example #4
0
 public function addLinkBy(Users $byUser, $url)
 {
     $data = array('url' => $url, 'linkable_id' => $this->id, 'linkable_type' => get_class($this), 'site_id' => Sites::findByUrl($url)->id, 'user_id' => $byUser->id);
     $link = new Links();
     $link->save($data);
     return $this;
 }
Example #5
0
 public function __construct()
 {
     parent::__construct();
     $this->Common = new Common();
     $Links = new Links();
     $this->links = $Links->order('lid', 'desc')->getAll();
 }
Example #6
0
 public function &OtherSiteLinks()
 {
     $ret = new Links();
     $links =& $this->Links();
     foreach ($links as $link) {
         if ($link->Type() == 'o') {
             $ret->Add($link);
         }
     }
     return $ret;
 }
 public function postCreate()
 {
     $validator = Validator::make(Input::all(), Links::$rules);
     if ($validator->passes()) {
         $link = new Links();
         $link->message = Input::get('message');
         $link->recipient_id = Input::get('recipient_id');
         $link->sender_id = Auth::user()->id;
         $link->save();
         return Redirect::back()->with('message', 'Your link was sent successfully!');
     } else {
         return Redirect::back()->with('message', 'Sorry! The following errors occured')->withErrors($validator)->withInput();
     }
 }
Example #8
0
 /**
  * list links
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // url is the link itself -- hack for xhtml compliance
         $url = str_replace('&', '&', $item['link_url']);
         // initialize variables
         $prefix = $suffix = '';
         // flag links that are dead, or created or updated very recently
         if ($item['edit_date'] >= $context['fresh']) {
             $suffix = NEW_FLAG;
         }
         // make a label
         $label = Links::clean($item['title'], $item['link_url']);
         // the main anchor link
         if (is_object($anchor)) {
             $suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #9
0
 public static function render($page, array $query_params = array())
 {
     if (substr($page, 0, 1) !== "/") {
         $page = "/" . $page;
     }
     ////
     // Fix for actions, look for '.php' in the referer
     //
     // There may be a better way to do this. Do you know?
     ////
     if (Links::$pretty === false && isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] !== "/" && isset($_SERVER['HTTP_REFERER']) && isset($_SERVER['HTTP_HOST'])) {
         //Remove http or https from $_SERVER['HTTP_REFERER']
         $referer = rtrim(str_replace(array("http://", "https://"), "", $_SERVER['HTTP_REFERER']), "/");
         if ($referer !== $_SERVER['HTTP_HOST'] && strpos($_SERVER['HTTP_REFERER'], ".php") === false) {
             Links::$pretty = true;
         }
     }
     if (Links::$pretty) {
         if (count($query_params) > 0) {
             return $page . "/" . implode("/", $query_params);
         }
         return $page;
     } else {
         if (count($query_params) > 0) {
             $params = array();
             for ($i = 0; $i < count($query_params); $i++) {
                 $params['param' . ($i + 1)] = $query_params[$i];
             }
             return $page . ".php?" . http_build_query($params);
         }
         return $page . ".php";
     }
 }
Example #10
0
 /**
  * list links
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // url is the link itself
         $url = $item['link_url'];
         // initialize variables
         $prefix = $suffix = '';
         // flag links that are dead, or created or updated very recently
         if ($item['edit_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         }
         // make a label
         $label = Links::clean($item['title'], $item['link_url'], 30);
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 public function store()
 {
     Notes::where('email', Auth::user()->email)->update(array('notes' => Input::get('notes')));
     TBD::where('email', Auth::user()->email)->update(array('tbd' => Input::get('tbd')));
     $input = Input::all();
     for ($i = 0; $i < count($input); $i++) {
         if (!Links::where('links', '=', Input::get("link{$i}"))->exists()) {
             if (Input::get("link{$i}") != "") {
                 Links::insert(array('email' => Auth::user()->email, 'links' => Input::get("link{$i}")));
             }
         }
     }
     if (Input::hasFile('photo')) {
         $count = Image::where('email', Auth::user()->email)->count();
         if ($count >= 4) {
             echo "USER CAN ONLY HAVE 4 PHOTOS MAX";
             return Redirect::back();
         }
         $extension = Input::file('photo')->getClientOriginalExtension();
         if ($extension == "gif" || $extension == "jpeg") {
             Image::insert(array('email' => Auth::user()->email, 'image' => file_get_contents(Input::file('photo'))));
         } else {
             echo "CAN ONLY DO GIF OR JPEG";
         }
     }
     $imageCount = Image::where('email', Auth::user()->email)->count();
     for ($i = 0; $i < $imageCount - 1; $i++) {
         if (Input::get("delete{$i}") != null) {
             $imageTable = Image::where('email', Auth::user()->email)->get();
             //echo $imageTable[$i+1]["id"];
             Image::where('id', $imageTable[$i]["id"])->delete();
         }
     }
     return Redirect::to('profile');
 }
Example #12
0
 private function handleConfigPost()
 {
     $request = Request::getInstance();
     $values = $request->getRequest(Request::POST);
     try {
         if (!$request->exists('tree_id')) {
             throw new Exception('Node ontbreekt.');
         }
         if (!$request->exists('tag')) {
             throw new Exception('Tag ontbreekt.');
         }
         $tree_id = intval($request->getValue('tree_id'));
         $tag = $request->getValue('tag');
         $key = array('tree_id' => $tree_id, 'tag' => $tag);
         if ($this->exists($key)) {
             $this->update($key, $values);
         } else {
             $this->insert($values);
         }
         viewManager::getInstance()->setType(ViewManager::TREE_OVERVIEW);
         $this->plugin->handleHttpGetRequest();
     } catch (Exception $e) {
         $template = new TemplateEngine();
         $template->setVariable('errorMessage', $e->getMessage(), false);
         $this->handleConfigGet(false);
     }
 }
Example #13
0
 /**
  * @param string $name
  * @param array $array
  * @param \WoohooLabs\Yang\JsonApi\Schema\ResourceObjects $resources
  */
 public function __construct($name, array $array, ResourceObjects $resources)
 {
     $this->name = $name;
     $this->meta = $this->isArrayKey($array, "meta") ? $array["meta"] : [];
     $this->links = Links::createFromArray($this->isArrayKey($array, "links") ? $array["links"] : []);
     if ($this->isArrayKey($array, "data")) {
         if ($this->isAssociativeArray($array["data"])) {
             $this->isToOneRelationship = true;
             if (empty($array["data"]["type"]) === false && empty($array["data"]["id"]) === false) {
                 $this->resourceMap = [["type" => $array["data"]["type"], "id" => $array["data"]["id"]]];
             }
         } else {
             $this->isToOneRelationship = false;
             $this->resourceMap = [];
             foreach ($array["data"] as $item) {
                 if (empty($item["type"]) === false && empty($item["id"]) === false) {
                     $this->resourceMap[] = ["type" => $item["type"], "id" => $item["id"]];
                 }
             }
         }
     } else {
         $this->isToOneRelationship = null;
     }
     $this->resources = $resources;
 }
 public function store()
 {
     if (!Input::has('email', 'password', 'confirmPassword')) {
         $this->failure("Must fill in the values");
     }
     if (Input::get('password') != Input::get('confirmPassword')) {
         $this->failure("PASSWORDS NOT THE SAME");
     }
     $rules = array('email' => 'unique:users,email');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $this->failure('That email address is already registered. You sure you don\'t have an account?');
     }
     if (!filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL)) {
         $this->failure("username must be an email");
     }
     $verificationCode = md5(time());
     User::insert(array('email' => Input::get('email'), 'password' => Hash::make(Input::get('password')), 'verification' => $verificationCode));
     Image::insert(array('email' => Input::get('email'), 'image' => ''));
     Notes::insert(array('email' => Input::get('email'), 'notes' => ''));
     TBD::insert(array('email' => Input::get('email'), 'tbd' => ''));
     Links::insert(array('email' => Input::get('email'), 'links' => ''));
     Mail::send('emails.emailMessage', array('code' => $verificationCode, 'email' => Input::get('email')), function ($message) {
         $message->to('*****@*****.**', 'Jan Ycasas')->subject('Welcome!');
     });
     echo "Go Log In";
     return Redirect::to('/');
 }
Example #15
0
    public static function render($current_page = "")
    {
        echo '<div class="navbar navbar-fixed-top">
			      <div class="navbar-inner">
			        <div class="container">
			          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
			      	 	<span class="icon-bar"></span>
			      	 	<span class="icon-bar"></span>
			      	 	<span class="icon-bar"></span>
			          </a>
			          <a class="brand" href="/">Commando.io</a>
			          <div class="nav-collapse">
			            <ul class="nav">';
        foreach (Navigation::$pages as $page => $icon) {
            if ($page === strtolower($current_page)) {
                echo '<li class="active">';
            } else {
                echo '<li>';
            }
            echo '<a href="' . Links::render($page) . '"><i class="' . $icon . '"></i> ' . ucfirst($page) . '</a></li>';
        }
        echo '</ul>';
        if (!empty(Navigation::$right)) {
            echo '<ul class="nav pull-right">' . Navigation::$right . '</ul>';
        }
        echo '</div>
			        </div>
			      </div>
			    </div>';
    }
Example #16
0
 /**
  * handle object post request
  */
 private function handleObjectPost($objectType)
 {
     // add object to renderlist
     $this->plugin->addRenderList($objectType);
     $this->handleSubNavigation();
     $obj = $this->plugin->getObject($objectType);
     $obj->handleHttpPostRequest();
 }
 function get_user_links()
 {
     $condition = array('user_id' => $this->uid, 'is_active' => 1);
     $Links = new Links();
     $category_list = $Links->load_category($condition);
     if (count($category_list) > 0) {
         $links_data_array = array();
         for ($counter = 0; $counter < count($category_list); $counter++) {
             $links_data_array[$counter]['category_id'] = $category_list[$counter]->category_id;
             $links_data_array[$counter]['category_name'] = $category_list[$counter]->category_name;
             $Links->user_id = $this->uid;
             $condition = array('category_id' => $category_list[$counter]->category_id, 'is_active' => 1);
             $links_array = $Links->load_link($condition);
             $links_data_array[$counter]['links'] = $links_array;
         }
         return $links_data_array;
     }
 }
Example #18
0
 public static function getHref($page_name, array $url_params_ar = array())
 {
     // set page parameter
     $url_params_ar['page'] = strtolower(trim($page_name));
     // build file path
     $module_root_path = TS_Module_HRM_PresencePlanning_Constants::MODULE_ROOT_PATH;
     $full_path = $module_root_path;
     // Build and return full link
     return $full_path . Links::getParametersString($url_params_ar);
 }
Example #19
0
 /**
  * format just one item
  *
  * @param array attributes of one item
  * @return array of ($url => array($prefix, $label, $suffix, ...))
  *
  * @see articles/edit.php
  **/
 function one(&$item)
 {
     global $context;
     // initialize variables
     $prefix = $suffix = $icon = '';
     // flag sections that are created or updated very recently
     if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
         $prefix .= EXPIRED_FLAG;
     } elseif ($item['create_date'] >= $context['fresh']) {
         $suffix .= NEW_FLAG;
     } elseif ($item['edit_date'] >= $context['fresh']) {
         $suffix .= UPDATED_FLAG;
     }
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $prefix .= PRIVATE_FLAG;
     } elseif ($item['active'] == 'R') {
         $prefix .= RESTRICTED_FLAG;
     }
     // details
     $details = array();
     // info on related files
     if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
     }
     // info on related links
     if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
     }
     // info on related comments
     if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
     }
     // append details to the suffix
     if (count($details)) {
         $suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
     }
     // introduction
     if ($item['introduction']) {
         $suffix .= ' ' . Codes::beautify_introduction($item['introduction']);
     }
     // add a head list of related links
     $subs = array();
     // put the actual icon in the left column
     if (isset($item['thumbnail_url'])) {
         $icon = $item['thumbnail_url'];
     }
     // url to select this article
     $url = 'articles/edit.php?template=' . $item['id'];
     // use the title to label the link
     $label = Skin::strip($item['title'], 50);
     // list all components for this item
     $output = array($url => array($prefix, $label, $suffix, 'article', $icon, i18n::s('Select this model')));
     return $output;
 }
Example #20
0
 public function actionIndex()
 {
     $this->pageTitle = $this->dataSystem->title;
     // Dang ky Internet
     $criInternet = new CDBCriteria();
     $criInternet->addCondition("category_news_id = 1");
     $criInternet->order = "id DESC";
     $criInternet->limit = 3;
     $arrInternet = News::model()->findAll($criInternet);
     //Dang ky cap quang
     $criOptical = new CDBCriteria();
     $criOptical->addCondition("category_news_id = 2");
     $criOptical->order = "id DESC";
     $criOptical->limit = 3;
     $arrOptical = News::model()->findAll($criOptical);
     //Store
     $criStore = new CDBCriteria();
     $criStore->addCondition("category_news_id = 6");
     $criStore->order = "id DESC";
     $criStore->limit = 3;
     $arrStore = News::model()->findAll($criStore);
     //CA
     $criCa = new CDBCriteria();
     $criCa->addCondition("category_news_id = 3");
     $criCa->order = "id DESC";
     $criCa->limit = 3;
     $arrCa = News::model()->findAll($criCa);
     //Sim - Card
     $criSimCard = new CDBCriteria();
     $criSimCard->addCondition("category_news_id = 4");
     $criSimCard->order = "id DESC";
     $criSimCard->limit = 3;
     $arrSimCard = News::model()->findAll($criSimCard);
     //TV
     $criTv = new CDBCriteria();
     $criTv->addCondition("category_news_id = 7");
     $criTv->order = "id DESC";
     $criTv->limit = 3;
     $arrTv = News::model()->findAll($criTv);
     /*Pictures*/
     $criPic = new CDbCriteria();
     $criPic->addCondition("album_id = 2");
     $criPic->order = "id DESC";
     $criPic->limit = 10;
     $arrPic = Images::model()->findAll($criPic);
     /*Slider*/
     $criBanner = new CDbCriteria();
     $criBanner->order = "id DESC";
     $criBanner->limit = 5;
     $arrBanner = Slides::model()->findAll($criBanner);
     /*Links web*/
     $arrLink = Links::model()->find();
     $this->render("index", array('arrBanner' => $arrBanner, 'arrInternet' => $arrInternet, 'arrOptical' => $arrOptical, 'arrStore' => $arrStore, 'arrCa' => $arrCa, 'arrSimCard' => $arrSimCard, 'arrTv' => $arrTv, 'arrLink' => $arrLink));
 }
Example #21
0
 /**
  * @param array $error
  * @return $this
  */
 public static function createFromArray(array $error)
 {
     $id = empty($error["id"]) === false ? $error["id"] : "";
     $meta = isset($error["meta"]) && is_array($error["meta"]) ? $error["meta"] : [];
     $links = Links::createFromArray(isset($error["links"]) && is_array($error["links"]) ? $error["links"] : []);
     $status = empty($error["status"]) === false ? $error["status"] : "";
     $code = empty($error["code"]) === false ? $error["code"] : "";
     $title = empty($error["title"]) === false ? $error["title"] : "";
     $detail = empty($error["detail"]) === false ? $error["detail"] : "";
     $source = ErrorSource::fromArray(isset($error["source"]) && is_array($error["source"]) ? $error["source"] : []);
     return new self($id, $meta, $links, $status, $code, $title, $detail, $source);
 }
Example #22
0
 public function actionIndex()
 {
     $model = Links::model()->find();
     if (!empty($_POST['Links'])) {
         $model->attributes = $_POST['Links'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', translate('Cập nhật thành công.'));
             $this->redirect(PIUrl::createUrl('/admin/links'));
         }
     }
     $this->render('index', array('model' => $model));
 }
Example #23
0
 /**
  * @param array $array
  * @param \WoohooLabs\Yang\JsonApi\Schema\ResourceObjects $resources
  */
 public function __construct($array, ResourceObjects $resources)
 {
     $this->type = empty($array["type"]) ? "" : $array["type"];
     $this->id = empty($array["id"]) ? "" : $array["id"];
     $this->meta = $this->isArrayKey($array, "meta") ? $array["meta"] : [];
     $this->links = Links::createFromArray($this->isArrayKey($array, "links") ? $array["links"] : []);
     $this->attributes = $this->isArrayKey($array, "attributes") ? $array["attributes"] : [];
     $this->relationships = [];
     if ($this->isArrayKey($array, "relationships")) {
         foreach ($array["relationships"] as $name => $relationship) {
             $this->relationships[$name] = new Relationship($name, $relationship, $resources);
         }
     }
 }
Example #24
0
 static function createForm($id, $action)
 {
     $form = new Form_Admin_Links($id, $action);
     $form->add(QForm::ELEMENT, 'name', array('_ui' => 'textbox', '_label' => '友情链接名称', '_req' => true, '_tips' => '友情链接的网站名'))->add(QForm::ELEMENT, 'url', array('_ui' => 'textbox', '_label' => '网站地址', '_req' => true, '_tips' => '友情链接网站的网址'))->add(QForm::ELEMENT, 'link_id', array('_ui' => 'hidden'))->add(QForm::ELEMENT, 'img', array('_ui' => 'admin_picpreview', '_label' => '已上传图片', 'attr' => array('dir' => 'links')))->add(QForm::ELEMENT, 'ico', array('_ui' => 'upload', '_label' => '上传图标', '_tips' => ''))->add(QForm::ELEMENT, 'order_num', array('_ui' => 'textbox', '_label' => '排序', 'value' => 0));
     $form->addValidations(Links::meta());
     //上传图片的限制
     $types = Q::normalize(Q::ini('appini/teapics/upload_allowed_types'));
     $size = intval(Q::ini('appini/teapics/upload_allowed_size') * 1024);
     $dim = Q::ini('appini/teapics/img_pic_width') . 'x' . Q::ini('appini/teapics/img_pic_height');
     $form['ico']->_tips = sprintf($form['ico']->_tips, implode('/', $types), $size / 1024, $dim);
     $form->selectUploadElement('ico')->uploadAllowedSize($size)->uploadAllowedTypes($types)->enableSkipUpload();
     //表单验证规则
     return $form;
 }
Example #25
0
 public static function toArray()
 {
     $arr = array();
     //Coloca os nomes
     $links = Links::model()->findAll();
     foreach ($links as $link) {
         $arr[] = $link->nome;
         foreach (explode(', ', $link->tags) as $tag) {
             if (!in_array($tag, $arr)) {
                 $arr[] = $tag;
             }
         }
     }
     //Coloca as tags
     return $arr;
 }
Example #26
0
function insertProcess()
{
    $send = Request::get('send');
    $valid = Validator::make(array('send.title' => 'required|min:1|slashes', 'send.parentid' => 'slashes', 'send.url' => 'required|min:1|slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request: " . Validator::getMessage());
    }
    $loadData = Links::get(array('where' => "where url='" . String::encode($send['url']) . "'"));
    if (isset($loadData[0]['url'])) {
        throw new Exception("This link exists in database.");
    }
    if (!($id = Links::insert($send))) {
        throw new Exception("Error. " . Database::$error);
    }
    $updateData = array('sort_order' => $id);
    Links::update($id, $updateData);
}
 public function index()
 {
     $post = array('alert' => '');
     Model::load('admincp/links');
     $curPage = 0;
     if ($match = Uri::match('\\/page\\/(\\d+)')) {
         $curPage = $match[1];
     }
     if (Request::has('btnAction')) {
         actionProcess();
     }
     if (Request::has('btnAdd')) {
         try {
             insertProcess();
             $post['alert'] = '<div class="alert alert-success">Add new link success.</div>';
         } catch (Exception $e) {
             $post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>';
         }
     }
     if (Request::has('btnSave')) {
         $match = Uri::match('\\/edit\\/(\\d+)');
         try {
             updateProcess($match[1]);
             $post['alert'] = '<div class="alert alert-success">Update link success.</div>';
         } catch (Exception $e) {
             $post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>';
         }
     }
     if (Request::has('btnSearch')) {
         filterProcess();
     } else {
         $post['pages'] = Misc::genSmallPage('admincp/links', $curPage);
         $post['theList'] = Links::get(array('limitShow' => 20, 'limitPage' => $curPage, 'orderby' => 'order by sort_order asc', 'cache' => 'no'));
     }
     if ($match = Uri::match('\\/edit\\/(\\d+)')) {
         $loadData = Links::get(array('where' => "where id='" . $match[1] . "'", 'cache' => 'no'));
         $post['edit'] = $loadData[0];
     }
     $post['listLinks'] = Links::get(array('orderby' => 'order by sort_order asc', 'cache' => 'no'));
     System::setTitle('Links list - ' . ADMINCP_TITLE);
     View::make('admincp/head');
     self::makeContents('linksList', $post);
     View::make('admincp/footer');
 }
 /**
  * 编辑新闻
  *
  */
 function actionEdit()
 {
     $link_id = intval($this->_context->link_id);
     //创建表单
     $form = Form_Admin_Links::createForm('links', url('links/edit'));
     $link = Links::find('link_id =?', $link_id)->query();
     $form->import($link);
     //是否是post提交 及通过验证
     if ($this->_context->isPOST() && $form->validate($_POST)) {
         try {
             $link->changeProps($form->values());
             $link->save();
             return $this->_redirectMessage('编辑友情链接成功', '如果你不做出选择系统将自动跳转', url('links/index'), 3);
         } catch (QValidator_ValidateFailedException $ex) {
             $form->invalidate($ex);
         }
     }
     $this->_view['form'] = $form;
     $this->_viewname = 'edit';
 }
Example #29
0
 /**
  * @param array $document
  * @return $this
  */
 public static function createFromArray(array $document)
 {
     if (isset($document["jsonApi"]) && is_array($document["jsonApi"])) {
         $jsonApi = $document["jsonApi"];
     } else {
         $jsonApi = [];
     }
     $jsonApiObject = JsonApi::createFromArray($jsonApi);
     if (isset($document["meta"]) && is_array($document["meta"])) {
         $meta = $document["meta"];
     } else {
         $meta = [];
     }
     if (isset($document["links"]) && is_array($document["links"])) {
         $links = $document["links"];
     } else {
         $links = [];
     }
     $linksObject = Links::createFromArray($links);
     if (isset($document["data"]) && is_array($document["data"])) {
         $data = $document["data"];
     } else {
         $data = [];
     }
     if (isset($document["included"]) && is_array($document["included"])) {
         $included = $document["included"];
     } else {
         $included = [];
     }
     $resources = new ResourceObjects($data, $included);
     $errors = [];
     if (isset($document["errors"]) && is_array($document["errors"])) {
         foreach ($document["errors"] as $error) {
             if (is_array($error)) {
                 $errors[] = Error::createFromArray($error);
             }
         }
     }
     return new self($jsonApiObject, $meta, $linksObject, $resources, $errors);
 }
Example #30
0
 public static function run($p = null, $root = null, $routes = true, $session = true, $whoops = true)
 {
     ob_start();
     //
     self::$page = $p;
     self::$root = $root;
     //
     //session
     require __DIR__ . '/../core/Storage/Session.php';
     if ($session) {
         Session::start(__DIR__ . '/../app/storage/session');
     }
     //
     require __DIR__ . '/../core/Access/ErrorHandler.php';
     // Config
     require __DIR__ . '/../core/Config/Config.php';
     require __DIR__ . '/../core/Config/Exceptions/ConfigException.php';
     //Maintenance
     require __DIR__ . '/../core/Maintenance/Maintenance.php';
     //Objects
     require __DIR__ . '/../core/Objects/Vars.php';
     require __DIR__ . '/../core/Objects/String/String.php';
     require __DIR__ . '/../core/Objects/String/Exceptions/StringOutIndexException.php';
     // Access
     require __DIR__ . '/../core/Access/Path.php';
     // Set the error log
     ini_set("log_errors", 1);
     ini_set("error_log", __DIR__ . '/../app/storage/logs/fiesta.log');
     // Set Whoops error handler
     if ($whoops) {
         ErrorHandler::ini(self::$root);
     }
     //
     //require __DIR__.'/../core/MVC/Templete.php';
     require __DIR__ . '/../core/Objects/Exception.php';
     require __DIR__ . '/../core/Faker.php';
     require __DIR__ . '/../core/Storage/Cookie.php';
     //routes
     // old
     //require __DIR__.'/../core/Access/Routes_2.php';
     // new
     require __DIR__ . '/../core/Router/Routes.php';
     require __DIR__ . '/../core/Router/Route.php';
     require __DIR__ . '/../core/Router/Exceptions/RouteNotFoundException.php';
     // Caches
     require __DIR__ . '/../core/Caches/Caches.php';
     require __DIR__ . '/../core/Caches/Cache.php';
     require __DIR__ . '/../core/Caches/FileCache.php';
     require __DIR__ . '/../core/Caches/DatabaseCache.php';
     require __DIR__ . '/../core/Caches/Exceptions/DriverNotFoundException.php';
     require __DIR__ . '/../core/Storage/Storage.php';
     require __DIR__ . '/../core/Security/Auth.php';
     require __DIR__ . '/../core/Objects/Table.php';
     // Database
     require __DIR__ . '/../core/Database/Schema.php';
     require __DIR__ . '/../core/Database/Migration.php';
     require __DIR__ . '/../core/Database/Seeder.php';
     require __DIR__ . '/../core/Database/Database.php';
     require __DIR__ . '/../core/Database/Drivers/MySql.php';
     require __DIR__ . '/../core/Database/Exceptions/DatabaseArgumentsException.php';
     require __DIR__ . '/../core/Database/Exceptions/DatabaseConnectionException.php';
     require __DIR__ . '/../core/Access/Url.php';
     require __DIR__ . '/../core/Hypertext/Pages.php';
     require __DIR__ . '/../core/Objects/DateTime.php';
     require __DIR__ . '/../core/Objects/Sys.php';
     require __DIR__ . '/../core/Http/Links.php';
     require __DIR__ . '/../core/Objects/Base.php';
     require __DIR__ . '/../core/Libs.php';
     require __DIR__ . '/../core/Hypertext/Res.php';
     require __DIR__ . '/../core/Hypertext/Input.php';
     require __DIR__ . '/../core/License.php';
     require __DIR__ . '/../core/Hypertext/Cookie.php';
     //Languages
     require __DIR__ . '/../core/Lang/Lang.php';
     require __DIR__ . '/../core/Lang/Exceptions/LanguageKeyNotFoundException.php';
     // MVC - model
     require __DIR__ . '/../core/MVC/Model/Model.php';
     require __DIR__ . '/../core/MVC/Model/ModelArray.php';
     require __DIR__ . '/../core/MVC/Model/Exceptions/ForeingKeyMethodException.php';
     require __DIR__ . '/../core/MVC/Model/Exceptions/ColumnNotEmptyException.php';
     require __DIR__ . '/../core/MVC/Model/Exceptions/ManyPrimaryKeysException.php';
     require __DIR__ . '/../core/MVC/Model/Exceptions/PrimaryKeyNotFoundException.php';
     // MVC - View
     require __DIR__ . '/../core/MVC/View/View.php';
     require __DIR__ . '/../core/MVC/View/Libs/Template.php';
     require __DIR__ . '/../core/MVC/View/Libs/Views.php';
     require __DIR__ . '/../core/MVC/View/Exceptions/ViewNotFoundException.php';
     require __DIR__ . '/../core/Hypertext/HTML.php';
     require __DIR__ . '/../core/Security/Encrypt.php';
     require __DIR__ . '/../core/Security.php';
     //require __DIR__.'/../core/MVC/Model.php';
     // require __DIR__.'/../core/MVC/View.php';
     require __DIR__ . '/../core/MVC/Controller.php';
     require __DIR__ . '/../core/Http/Error.php';
     require __DIR__ . '/../core/Hypertext/Script.php';
     require __DIR__ . '/../core/Http/Root.php';
     require __DIR__ . '/../core/Mail_2.php';
     require __DIR__ . '/../core/Objects/DataCollection.php';
     require __DIR__ . '/../core/Debug.php';
     // Filesystem
     require __DIR__ . '/../core/Filesystem/Exceptions/FileNotFoundException.php';
     require __DIR__ . '/../core/Filesystem/Exceptions/DirectoryNotFoundException.php';
     require __DIR__ . '/../core/Filesystem/Filesystem.php';
     // Database files
     require __DIR__ . '/../core/Database/DBTable.php';
     Sys::ini();
     Url::ini();
     Path::ini();
     Fiesta\MVC\View\Template::ini(self::$root);
     //
     Faker::ini();
     Links::ini();
     Errors::ini($root);
     License::ini(self::$page);
     Lang::ini();
     Database::ini();
     Auth::ini();
     //
     if ($root != null) {
         // include models
         foreach (glob($root . "../app/models/*.php") as $file) {
             include_once $file;
         }
         //include the controllers files
         foreach (glob($root . "../app/controllers/*.php") as $file) {
             include_once $file;
         }
         //include the link files
         foreach (glob($root . "../app/paths/*.php") as $file) {
             include_once $file;
         }
         //include the seeders files
         foreach (glob($root . "../app/seeds/*.php") as $file) {
             include_once $file;
         }
         //
         //include filters
         include_once $root . "../app/http/Filters.php";
         //include for routes
         if ($routes) {
             include_once $root . "../app/http/Routes.php";
             Fiesta\Router\Routes::run();
         }
     } else {
         // include models
         foreach (glob("../app/models/*.php") as $file) {
             include_once $file;
         }
         //include the controllers files
         foreach (glob("../app/controllers/*.php") as $file) {
             include_once $file;
         }
         //include the seeders files
         foreach (glob("../app/seeds/*.php") as $file) {
             include_once $file;
         }
         //include filters
         include_once "../app/http/Filters.php";
         //include for routes
         if ($routes) {
             include_once "../app/http/Routes.php";
             Fiesta\Router\Routes::run();
         }
     }
 }