public function delete($id) { if ($id) { $data = new Prefix($id); $action = 'DELETE'; save_logs($this->menu_id, $action, @$data->id, $action . ' ' . $data->org_name . ' Prefixes '); $data->delete(); } redirect("admin/settings/prefixes"); }
public function actionIndex() { $prefixs = Prefix::model()->findAll(); foreach ($prefixs as $prefix) { $this->updateSource($prefix); } }
public static function populatePrefixes($xhtml) { $c = new Criteria(); $prefixes = self::doSelect($c); foreach ($xhtml->body->ol->li as $value) { $uri = (string) $value['content']; $prefix = (string) $value->a; $rank = (int) $value->span['content']; //lookup prefix by prefix $old = self::findByPrefix($prefix); if (!$old) { $old = new \Prefix(); $old->setPrefix($prefix); } $old->setUri($uri); $old->setRank($rank); $old->save(); } return $prefixes; }
/** * Seed the prefixes table based on the prefixes json file * * @return void */ private function seedPrefixes() { // Empty the ontology table \Prefix::truncate(); // Fetch the ontology from the json file $prefixes = json_decode(file_get_contents(app_path() . '/database/seeds/data/prefixes.json'), true); foreach ($prefixes as $prefix => $uri) { \Prefix::create(array('prefix' => $prefix, 'uri' => $uri)); } $this->command->info("Added the prefixes and corresponding uri's."); }
public function actionCreate1() { $model = new Link(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $model->dataset_id = 1; $link_database = array(); //retrieve the database if (!isset($_SESSION['link_database'])) { $models = Prefix::model()->findAll(); $database = array(); foreach ($models as $m) { $value = $m->prefix; array_push($database, $value); } sort($database); $_SESSION['link_database'] = $database; } $link_database = $_SESSION['link_database']; //update if (!isset($_SESSION['links'])) { $_SESSION['links'] = array(); } $links = $_SESSION['links']; if (isset($_POST['Link'])) { $link = $link_database[$_POST['Link']['database']] . ":" . $_POST['Link']['acc_num']; $is_primary = 1; $model->attributes = $_POST['Link']; $model->link = $link; $model->is_primary = $is_primary; $id = 0; if ($this->storeLink($model, $id)) { $link_type = "ext_acc_mirror"; if ($is_primary == 0) { $link_type = "ext_acc_link"; } $newItem = array('id' => $id, 'link' => $link, 'link_type' => $link_type); array_push($links, $newItem); $_SESSION['links'] = $links; $vars = array('links'); //Dataset::storeSession($vars); $model = new Link(); } } $link_model = new CArrayDataProvider($links); $this->render('create1', array('model' => $model, 'link_model' => $link_model, 'link_database' => $link_database)); }
public function getFullUrl($source = '') { $temp = explode(":", trim($this->link)); $prefix = $temp[0]; $value = $temp[1]; $model = Prefix::model()->find("lower(prefix) = :p and source = :s", array(':p' => strtolower($prefix), ':s' => $source)); // find url with preferred source if ($model) { return $model->url . $value; } // if not get available url $model = Prefix::model()->find("lower(prefix) = :p", array(':p' => strtolower($prefix))); if ($model) { return $model->url . $value; } return "#"; }
/** * Create and return the semantic context * * @return mixed */ private function getContext() { $ns = \Prefix::all(); $context = new \stdClass(); $namespaces = new \stdClass(); $context_keyword = '@context'; foreach ($ns as $namespace) { $namespaces->{$namespace}['prefix'] = $namespace['uri']; } $context->{$context_keyword} = $namespaces; return $context; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Prefix::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function getLinkName() { $prefix = "SAMPLE:"; $len = strlen($prefix); $name = $this->name; $prefer = 'EBI'; if (!Yii::app()->user->isGuest) { $user = User::model()->findByPk(Yii::app()->user->_id); if ($user) { $prefer = $user->preferred_link; } } if (substr($name, 0, $len) == $prefix) { $linkName = substr($name, $len, strlen($name)); $prefix_text = 'sample'; $criteria = new CDbCriteria(); $criteria->compare('lower(prefix)', $prefix_text); $criteria->compare('source', $prefer); $criteria->limit = 1; $prefix_models = Prefix::model()->findAll($criteria); if (!$prefix_models) { $criteria = new CDbCriteria(); } $criteria->compare('lower(prefix)', $prefix_text); $criteria->limit = 1; $prefix_models = Prefix::model()->findAll($criteria); $link = ''; if ($prefix_models) { $link = $prefix_models[0]->url . $linkName; } return CHtml::link($linkName, $link, array('target' => '_blank')); } return $name; }