Example #1
0
 /**
  * @copydoc Saver::save
  *
  * @note After saving site data it creates new section, translations and rights.
  */
 public function save()
 {
     $mainTableName = 'share_sites';
     if (isset($_POST[$mainTableName]['site_is_default']) && $_POST[$mainTableName]['site_is_default'] !== '0') {
         $this->dbh->modify(QAL::UPDATE, $mainTableName, array('site_is_default' => '0'));
     }
     $result = parent::save();
     $id = $this->getMode() == QAL::INSERT ? $result : $this->getData()->getFieldByName('site_id')->getRowData(0);
     //Сохраняем информацию о доменах
     $domainIDs = $this->dbh->getColumn('SELECT domain_id FROM share_domains WHERE domain_id NOT IN (SELECT domain_id FROM share_domain2site)');
     if (!empty($domainIDs)) {
         foreach ($domainIDs as $domainID) {
             $this->dbh->modify(QAL::INSERT, 'share_domain2site', array('site_id' => $id, 'domain_id' => $domainID));
         }
     }
     //Записываем информацию в таблицу тегов
     $tm = new TagManager($this->dataDescription, $this->data, 'share_sites');
     $tm->save($id);
     if ($this->getMode() == QAL::INSERT) {
         //При создании нового проекта   ищем параметр конфигурации указывающий на идентификатор
         //шаблонного раздела
         if (isset($_POST['copy_site_structure'])) {
             $this->copyStructure((int) $_POST['copy_site_structure'], $id);
         } else {
             $this->createMainPage($id);
         }
     }
     return $result;
 }
Example #2
0
 /**
  * Save data into the table of uploads and tags.
  */
 public function save()
 {
     $result = parent::save();
     $entityID = $this->getMode() == QAL::INSERT ? $result : $this->getData()->getFieldByName($this->pk)->getRowData(0);
     $tm = new TagManager($this->dataDescription, $this->data, $this->mainTableName);
     $tm->save($entityID);
     // обновление записей из _uploads таблицы, в которых PK = NULL по ID сессии
     if ($result && $this->dbh->tableExists($this->getTableName() . AttachmentManager::ATTACH_TABLE_SUFFIX)) {
         $id = is_int($result) ? $result : (int) $_POST[$this->getTableName()][$this->getPK()];
         //throw new SystemException($id);
         $this->dbh->modify(QAL::UPDATE, $this->getTableName() . AttachmentManager::ATTACH_TABLE_SUFFIX, array($this->getPK() => $id), array($this->getPK() => null, 'session_id' => session_id()));
     }
     return $result;
 }
 /**
  * Initializes the FTL Manager.
  * 
  * @return void
  */
 public static function init()
 {
     if (self::$_inited) {
         return;
     }
     self::$_inited = TRUE;
     self::$ci =& get_instance();
     self::$context = new FTL_ArrayContext();
     // Inlude array of module definition. This file is generated by module installation in Ionize.
     // This file contains definition for installed modules only.
     include APPPATH . 'config/modules.php';
     // Put modules arrays keys to lowercase
     if (!empty($modules)) {
         self::$module_folders = array_combine(array_map('strtolower', array_values($modules)), array_values($modules));
     }
     // Loads automatically all installed modules tags
     foreach (self::$module_folders as $module) {
         self::autoload_module_tags($module . '_Tags');
     }
     // Load automatically all TagManagers defined in /libraries/Tagmanager
     $tagmanagers = glob(APPPATH . 'libraries/Tagmanager/*' . EXT);
     foreach ($tagmanagers as $tagmanager) {
         self::autoload(array_pop(explode('/', $tagmanager)));
     }
     self::add_globals('TagManager');
     self::add_tags();
     self::add_module_tags();
 }
Example #4
0
 public static function getInstance()
 {
     if (!self::$orderManager) {
         self::$tagManager = new TagManager();
         self::$tagDataStore = new BeanDataStore(Tag::$className, Tag::$tableName);
         return self::$tagManager;
     }
     return self::$tagManager;
 }
Example #5
0
 public static function loadBasicDummyData()
 {
     TestManager::clearDatabase();
     $database = new DatabaseManager();
     UserManager::verifyTable($database);
     AddonManager::verifyTable($database);
     BoardManager::verifyTable($database);
     TagManager::verifyTable($database);
     GroupManager::verifyTable($database);
     DependencyManager::verifyTable($database);
     CommentManager::verifyTable($database);
     RatingManager::verifyTable($database);
     BuildManager::verifyTable($database);
     StatManager::verifyTable($database);
     ScreenshotManager::verifyTable($database);
     if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('General Content', 'general_content_bg', 'Bricks, Events, Sounds, Prints, Environments, and much more!')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('Minigames', 'minigames_bg', 'Weapons, Vehicles, Gamemodes, and all your gaming needs!')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('Client Mods', 'client_mods_bg', 'Mods that run on your client.')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('Bargain Bin', 'bargain_bin_bg', 'A home for \\'special\\' content.')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `users` (username, blid, password, email, salt, verified) VALUES ('testuser', '4833', '1d8436e97ef95a7a6151f47b909167c77cfe1985ee5500efa8d46cfe825abc59', '*****@*****.**', '273eb4', '1')")) {
         throw new Exception("Database error: " . $database->error());
     }
     //the default json types likely need to be reworked
     if (!$database->query("INSERT INTO `addon_addons` (board, blid, name, filename, description, approved, versionInfo, authorInfo, reviewInfo) VALUES ('1', '4833', 'crapy adon', 'sciprt_hax.zip', 'bad addone pls delete', '1', '{}', '[]', '[]')")) {
         throw new Exception("Database error: " . $database->error());
     }
     StatManager::addStatsToAddon(1);
     if (!$database->query("INSERT INTO `addon_tags` (name, base_color, icon) VALUES ('dum tag', 'ff6600', 'brokenimage')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_tagmap` (aid, tid) VALUES ('1', '1')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `group_groups` (leader, name, description, color, icon) VALUES ('4833', 'legion of dumies', 'a group for people who just want to be in a group', '00ff00', 'brokenimage')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `group_usermap` (gid, blid, administrator) VALUES ('1', '4833', '1')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_comments` (blid, aid, comment) VALUES ('4833', '1', 'glorious addon comrade')")) {
         throw new Exception("Database error: " . $database->error());
     }
     if (!$database->query("INSERT INTO `addon_ratings` (blid, aid, rating) VALUES ('4833', '1', '1')")) {
         throw new Exception("Database error: " . $database->error());
     }
 }
Example #6
0
 public function testRemoveTag2()
 {
     $this->testAddTag();
     $response = TagManager::removeTagIDFromAddonID(1, 1);
     $this->assertTrue($response);
     $this->assertFalse(TagManager::getFromID(1));
     $tag = TagManager::getFromID(2);
     $this->assertNotEquals(false, $tag);
     $this->assertEquals("new tag", $tag->getName());
     $tags = TagManager::getTagsFromAddonID(1);
     $this->assertEquals(1, count($tags));
     $obj = TagManager::getFromID($tags[0]);
     $this->assertEquals("new tag", $obj->getName());
 }
Example #7
0
 /**
  * 
  * @param ITag $tag
  */
 public function removeTag(ITag $tag)
 {
     TagManager::getInstance()->removeTag($this, $tag);
 }
Example #8
0
 /**
  * Unregister the shutdown function
  *
  */
 private static function unregister_shutdown()
 {
     self::$shutdown_callback = NULL;
     self::$shutdown_callback_args = NULL;
 }
Example #9
0
 public function add_globals()
 {
     parent::add_globals();
     // Get current asked page
     self::$context->globals->page = self::get_current_page(self::$ci->uri->segment(3));
     // Show 404 if no page
     if (empty(self::$context->globals->page)) {
         self::set_404();
     }
 }
Example #10
0
 /**
  * @param string $tag
  * @return array
  */
 public function getPagesByTag($tag)
 {
     return $this->dbh->getColumn('SELECT *
     FROM `share_sitemap_tags` st
     RIGHT JOIN share_sitemap s On (st.smap_id = s.smap_id) AND (s.site_id= %s)
     WHERE tag_id IN (%s)', $this->siteID, array_keys(TagManager::getID($tag)));
 }
Example #11
0
 public function getTags()
 {
     return TagManager::getTagsFromAddonID($this->id);
 }
Example #12
0
 public function executeRmtag(sfWebRequest $request)
 {
     $e = $request->getParameter('e', false);
     $id = $request->getParameter('id', false);
     $type = $request->getParameter('type', false);
     TagManager::removeTag($id, $e, $type);
     switch ($type) {
         case Politico::NUM_ENTITY:
             $this->entity = PoliticoPeer::retrieveByPK($e);
             break;
         case Partido::NUM_ENTITY:
             $this->entity = PartidoPeer::retrieveByPK($e);
             break;
         case Propuesta::NUM_ENTITY:
             $this->entity = PropuestaPeer::retrieveByPK($e);
             break;
     }
 }
 /**
  * If the response has tags for invalidation, invalidate them.
  *
  * @param Response $response
  */
 private function invalidateTagsFromResponse(Response $response)
 {
     $tags = $this->decodeTags($response->headers->get($this->options['header_invalidate_tags']));
     $this->manager->invalidateTags($tags);
 }
Example #14
0
 public function __construct(TagModule $module)
 {
     parent::__construct($module);
     TagManager::$instance = $this;
 }
 /**
  * Create field.
  * It is used in feeds and their derivatives.
  *
  * @param bool|string $mapFieldName Map field name.
  * @param bool $returnOnlyFirstAttachment Defines whether only the first attachment should be returned.
  * @param bool|array $mapValue Map values.
  */
 public function createField($mapFieldName = false, $returnOnlyFirstAttachment = false, $mapValue = false)
 {
     if ($this->isActive && !$this->data->isEmpty()) {
         if (!$mapFieldName) {
             $mapFieldName = $this->pk->getName();
         }
         if (!$mapValue) {
             if (!($f = $this->data->getFieldByName($mapFieldName))) {
                 return;
             }
             $mapValue = $f->getData();
         }
         $mapTableName = $this->tableName;
         //@todo в принципе имя филда можеть быть вычислено через ColumnInfo
         $f = new Field('attachments');
         $this->data->addField($f);
         if (!is_array($mapValue)) {
             $mapValue = [$mapValue];
         }
         if ($filteredMapValue = array_filter(array_values($mapValue))) {
             $langMapTableName = $this->dbh->getTranslationTablename($mapTableName);
             $columns = $this->dbh->getColumnsInfo($mapTableName);
             $prefix = '';
             foreach ($columns as $cname => $col) {
                 if (isset($col['index']) && $col['index'] == 'PRI') {
                     $prefix = str_replace('_id', '', $cname);
                 }
             }
             if ($langMapTableName) {
                 $lang_columns = $this->dbh->getColumnsInfo($langMapTableName);
                 $lang_pk = false;
                 foreach ($lang_columns as $cname => $col) {
                     if (isset($col['index']) && $col['index'] == 'PRI' && $cname != 'lang_id') {
                         $lang_pk = $cname;
                     }
                 }
             }
             $additional_fields = [];
             foreach ($columns as $cname => $col) {
                 if ($cname != 'session_id' && (empty($col['index']) or $col['index'] != 'PRI' and empty($col['key']['tableName']))) {
                     $new_cname = str_replace($prefix . '_', '', $cname);
                     if ($new_cname != 'order_num') {
                         $additional_fields[$cname] = $new_cname;
                     }
                 }
             }
             if ($langMapTableName) {
                 foreach ($lang_columns as $cname => $col) {
                     if (empty($col['index']) or $col['index'] != 'PRI') {
                         $new_cname = str_replace($prefix . '_', '', $cname);
                         if ($new_cname != 'name') {
                             $additional_fields[$cname] = $new_cname;
                         }
                     }
                 }
             }
             $request = 'SELECT spu.' . $mapFieldName . ',spu.upl_id as id, spu.*, ' . 'upl_path as file, upl_name as name, upl_title as title, upl_width as width, upl_height as height, TIME_FORMAT(upl_duration, "%i:%s") as duration,
                         upl_internal_type as type,upl_mime_type as mime, upl_data as data, ' . 'upl_is_mp4 as is_mp4, upl_is_webm as is_webm, upl_is_flv as is_flv ' . ($langMapTableName && $lang_pk ? ', spt.*' : '') . 'FROM ' . self::ATTACH_TABLENAME . ' su ' . 'LEFT JOIN `' . $mapTableName . '` spu ON spu.upl_id = su.upl_id ' . ($langMapTableName && $lang_pk ? 'LEFT JOIN `' . $langMapTableName . '` spt ON spu.' . $lang_pk . ' = spt.' . $lang_pk . ' AND spt.lang_id = ' . E()->getDocument()->getLang() : '') . ' WHERE ' . $mapFieldName . ' IN (' . implode(',', $filteredMapValue) . ') AND (su.upl_is_ready=1) AND (su.upl_is_active = 1)';
             // получаем имя колонки _order_num и сортируем по этому полю, если оно есть
             if ($columns) {
                 foreach ($columns as $col => $colInfo) {
                     if (strpos($col, '_order_num') !== false) {
                         $request .= ' ORDER BY ' . $col;
                     }
                 }
             }
             $images = $this->dbh->select($request);
             if ($images) {
                 foreach ($images as $row) {
                     $repoPath = E()->FileRepoInfo->getRepositoryRoot($row['file']);
                     $row['secure'] = E()->getConfigValue('repositories.ftp.' . $repoPath . '.secure', 0) ? true : false;
                     // делаем преобразование имен из $additional_fiels (отрезаем prefix)
                     if ($additional_fields) {
                         foreach ($additional_fields as $old_field => $new_field) {
                             if (array_key_exists($old_field, $row)) {
                                 $val = $row[$old_field];
                                 unset($row[$old_field]);
                                 $row[$new_field] = $val;
                             }
                         }
                     }
                     $mapID = $row[$mapFieldName];
                     if ($returnOnlyFirstAttachment && isset($imageData[$mapID])) {
                         continue;
                     }
                     if (!isset($imageData[$mapID])) {
                         $imageData[$mapID] = [];
                     }
                     array_push($imageData[$mapID], $row);
                 }
                 list($uploadsPK) = array_keys($columns);
                 for ($i = 0; $i < sizeof($mapValue); $i++) {
                     if (isset($imageData[$mapValue[$i]])) {
                         if ($this->addOG) {
                             foreach ($imageData[$mapValue[$i]] as $row) {
                                 E()->getOGObject()->addImage($row['file']);
                             }
                             $attachment = $imageData[$mapValue[$i]];
                             if (isset($attachment[0]) && $attachment[0]['type'] === 'video') {
                                 //inspect($attachment);
                                 E()->getOGObject()->setVideo($attachment[0]['file'], $attachment[0]['duration'], $attachment[0]['mime'], $attachment[0]['width'], $attachment[0]['height']);
                             }
                         }
                         $builder = new SimplestBuilder();
                         $localData = new Data();
                         $localData->load($imageData[$mapValue[$i]]);
                         $dataDescription = new DataDescription();
                         $fd = new FieldDescription('id');
                         $dataDescription->addFieldDescription($fd);
                         $fd = new FieldDescription($uploadsPK);
                         $fd->setType(FieldDescription::FIELD_TYPE_INT);
                         $fd->setProperty('key', true);
                         $dataDescription->addFieldDescription($fd);
                         $fd = new FieldDescription('file');
                         $fd->setType(FieldDescription::FIELD_TYPE_STRING);
                         $base = pathinfo($imageData[$mapValue[$i]][0]['file'], PATHINFO_DIRNAME) . '/' . pathinfo($imageData[$mapValue[$i]][0]['file'], PATHINFO_FILENAME);
                         $dataDescription->addFieldDescription($fd);
                         $fd = new FieldDescription('type');
                         $fd->setType(FieldDescription::FIELD_TYPE_STRING);
                         $dataDescription->addFieldDescription($fd);
                         $fd = new FieldDescription('duration');
                         $fd->setType(FieldDescription::FIELD_TYPE_STRING);
                         $dataDescription->addFieldDescription($fd);
                         $fd = new FieldDescription('width');
                         $fd->setType(FieldDescription::FIELD_TYPE_STRING);
                         $dataDescription->addFieldDescription($fd);
                         $fd = new FieldDescription('height');
                         $fd->setType(FieldDescription::FIELD_TYPE_STRING);
                         $dataDescription->addFieldDescription($fd);
                         $fd = new FieldDescription('mime');
                         $fd->setType(FieldDescription::FIELD_TYPE_STRING);
                         $dataDescription->addFieldDescription($fd);
                         $fd = new FieldDescription('data');
                         $fd->setType(FieldDescription::FIELD_TYPE_STRING);
                         $dataDescription->addFieldDescription($fd);
                         $fd = new FieldDescription('title');
                         $fd->setType(FieldDescription::FIELD_TYPE_STRING);
                         $dataDescription->addFieldDescription($fd);
                         $fd_name = new FieldDescription('name');
                         $dataDescription->addFieldDescription($fd_name);
                         $fd = new FieldDescription('secure');
                         $fd->setType(FieldDescription::FIELD_TYPE_HIDDEN);
                         $dataDescription->addFieldDescription($fd);
                         $playlist = [];
                         foreach (['mp4', 'webm', 'flv'] as $fileType) {
                             if ($imageData[$mapValue[$i]][0]['is_' . $fileType] == '1') {
                                 $playlist[] = ['id' => $base . '.' . $fileType, 'type' => $fileType];
                             }
                         }
                         if ($playlist && count($playlist) > 1) {
                             $fd = new FieldDescription('playlist');
                             $fd->setType(FieldDescription::FIELD_TYPE_SELECT);
                             $fd->loadAvailableValues($playlist, 'id', 'id');
                             $dataDescription->addFieldDescription($fd);
                         }
                         // дополнительные поля из основной и языковой таблицы _uploads
                         foreach ($additional_fields as $new_name) {
                             if ($new_name != 'name') {
                                 $fd = new FieldDescription($new_name);
                                 $fd->setType(FieldDescription::FIELD_TYPE_STRING);
                                 $dataDescription->addFieldDescription($fd);
                             }
                         }
                         $builder->setData($localData);
                         $builder->setDataDescription($dataDescription);
                         if ($this->dbh->getTagsTablename($mapTableName)) {
                             $tm = new TagManager($dataDescription, $localData, $mapTableName);
                             $tm->createFieldDescription();
                             $tm->createField();
                         }
                         $builder->build();
                         $f->setRowData($i, $builder->getResult());
                     }
                 }
             }
         }
     }
 }
Example #16
0
 public static function removeTagFromAddon($tag, $addon)
 {
     $database = new DatabaseManager();
     TagManager::verifyTable($database);
     $resource = $database->query("SELECT 1 FROM `addon_tagmap` WHERE\n\t\t\t`tid` = '" . $database->sanitize($tag->getID()) . "' AND\n\t\t\t`aid` = '" . $database->sanitize($addon->getID()) . "' LIMIT 1");
     if (!$resource) {
         throw new Exception("Database error: " . $database->error());
     }
     if ($resource->num_rows == 0) {
         $resource->close();
         return false;
     }
     $resource->close();
     if (!$database->query("DELETE FROM `addon_tagmap` WHERE\n\t\t\t`tid` = '" . $database->sanitize($tag->getID()) . "' AND\n\t\t\t`aid` = '" . $database->sanitize($addon->getID()) . "'")) {
         throw new Exception("Error removing tagmap entry: " . $database->error());
     }
     if (!$tag->getImportant()) {
         //now check to see if there are any other instances of tag
         $resource = $database->query("SELECT 1 FROM `addon_tagmap` WHERE\n\t\t\t\t`tid` = '" . $database->sanitize($tag->getID()) . "' LIMIT 1");
         if ($resource->num_rows == 0) {
             if (!$database->query("DELETE FROM `addon_tags` WHERE\n\t\t\t\t\t`id` = '" . $database->sanitize($tag->getID()) . "'")) {
                 throw new Exception("Error deleting tag: " . $database->error());
             }
             apc_delete('tagObject_' . $tag->getID());
             apc_delete('allTags');
         }
         $resource->close();
     }
     apc_delete('addonTags_' . $addon->getID());
     apc_delete('tagAddons_' . $tag->getID());
     return true;
 }
Example #17
0
 /**
  * Aggiorna il post e le sue dipendenze nel database.
  * Le dipendenze aggiornate sono quelle che dipendono dall'autore ovvero: tag e categorie
  * Potrebbe salvare alcune tuple in Tag.
  *
  * @return: modificationDate o FALSE se c'è un errore.
  */
 function update()
 {
     require_once "query.php";
     $db = new DBManager();
     if (!$db->connect_errno()) {
         define_tables();
         definePostColumns();
         $table = Query::getDBSchema()->getTable(TABLE_POST);
         $rs = $db->execute($s = Query::generateSelectStm(array($table), array(), array(new WhereConstraint($table->getColumn(POST_ID), Operator::EQUAL, $this->getID())), array()), $table->getName(), $this);
         //echo "<br />" . $s; //DEBUG
         $data = array();
         if ($db->num_rows() == 1) {
             $row = $db->fetch_result();
             //cerco le differenze e le salvo.
             if ($row[POST_TITLE] != $this->getTitle()) {
                 $data[POST_TITLE] = $this->getTitle();
             }
             if ($row[POST_SUBTITLE] != $this->getSubtitle()) {
                 $data[POST_SUBTITLE] = $this->getSubtitle();
             }
             if ($row[POST_HEADLINE] != $this->getHeadline()) {
                 $data[POST_HEADLINE] = $this->getHeadline();
             }
             if ($row[POST_CONTENT] != $this->getContent()) {
                 if ($this->type == "post" || $this->type == "news" || $this->type == "videoreportage") {
                     $data[POST_CONTENT] = $this->getContent();
                 } else {
                     $data[POST_CONTENT] = serialize($this->getContent());
                 }
             }
             if ($row[POST_PLACE] != $this->getPlace()) {
                 $data[POST_PLACE] = $this->getPlace();
             }
             if ($row[POST_TAGS] != $this->getTags()) {
                 $data[POST_TAGS] = $this->getTags();
             }
             if ($row[POST_CATEGORIES] != $this->getCategories()) {
                 // check sulle categorie, eliminazione di quelle che non esistono nel sistema, se vuoto inserimento di quella di default
                 $new_cat = CategoryManager::filterWrongCategories(explode(",", $this->getCategories()));
                 if (count($new_cat) == 0) {
                     $new_cat[] = self::DEFAULT_CATEGORY;
                 }
                 $this->setCategories(Filter::arrayToText($new_cat));
                 $data[POST_CATEGORIES] = $this->getCategories();
             }
             settype($row[POST_VISIBLE], "boolean");
             if ($row[POST_VISIBLE] !== $this->isVisible()) {
                 $data[POST_VISIBLE] = $this->isVisible() ? 1 : 0;
             }
             if ($row[POST_PERMALINK] != $this->getPermalink()) {
                 if (self::permalinkExists($this->getPermalink())) {
                     return false;
                 }
                 $data[POST_PERMALINK] = $this->getPermalink();
             }
             if (count($data) == 0) {
                 return $this->getModificationDate();
             }
             $data[POST_MODIFICATION_DATE] = date("Y/m/d G:i:s", $_SERVER["REQUEST_TIME"]);
             // se mi dicono di fare l'update, cambio modificationDate
             //echo "<br />" . serialize($data); //DEBUG
             $rs = $db->execute($s = Query::generateUpdateStm($table, $data, array(new WhereConstraint($table->getColumn(POST_ID), Operator::EQUAL, $this->getID()))), $table->getName(), $this);
             //echo "<br />" . $s; //DEBUG
             //echo "<br />" . mysql_affected_rows(); //DEBUG
             if ($db->affected_rows() == 1) {
                 //salvo i tag che non esistono
                 if (isset($data[POST_TAGS]) && !is_null($data[POST_TAGS]) && trim($data[POST_TAGS]) != "") {
                     TagManager::createTags(explode(",", $data[POST_TAGS]));
                 }
                 //echo "<br />" . $this; //DEBUG
                 return $this->getModificationDate();
             } else {
                 $db->display_error("Post::update()");
             }
         } else {
             $db->display_error("Post::update()");
         }
     } else {
         $db->display_connect_error("Post::update()");
     }
     return false;
 }
 /**
  * Unassign tags from a file.
  *
  * @param array $params (
  * 		path => string,
  * 		tagIds => array(
  *			tagId1, tagId2, ...
  *		)
  * )
  */
 public function removeAllTags($params)
 {
     if ($params === null) {
         throw new EyeInvalidArgumentException('Missing $params');
     }
     if (!isset($params['path']) || !is_string($params['path'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $params[\'path\']');
     }
     if (!isset($params['tagIds']) || !is_array($params['tagIds'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $params[\'tagIds\']');
     }
     $file = FSI::getFile($params['path']);
     $TM = TagManager::getInstance();
     $tags = array();
     foreach ($params['tagIds'] as $tagId) {
         $tag = new BasicTag();
         $tag->setId($tagId);
         $TM->getTag($tag);
         $tags[] = $tag;
     }
     $TM->removeAllTags($file, $tags);
 }
Example #19
0
 public static function verifyTable($database)
 {
     if ($database->debug()) {
         UserManager::verifyTable($database);
         AddonManager::verifyTable($database);
         TagManager::verifyTable($database);
         BuildManager::verifyTable($database);
         GroupManager::verifyTable($database);
         if (!$database->query("CREATE TABLE IF NOT EXISTS `addon_stats` (\n\t\t\t\t`aid` INT NOT NULL,\n\t\t\t\t`rating` FLOAT,\n\t\t\t\t`totalDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`iterationDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`webDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`ingameDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`updateDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\tKEY (`totalDownloads`),\n\t\t\t\tKEY (`iterationDownloads`),\n\t\t\t\tFOREIGN KEY (`aid`)\n\t\t\t\t\tREFERENCES addon_addons(`id`)\n\t\t\t\t\tON UPDATE CASCADE\n\t\t\t\t\tON DELETE CASCADE)")) {
             throw new Exception("Failed to create addon stats table: " . $database->error());
         }
         if (!$database->query("CREATE TABLE IF NOT EXISTS `build_stats` (\n\t\t\t\t`bid` INT NOT NULL,\n\t\t\t\t`rating` FLOAT,\n\t\t\t\t`totalDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`iterationDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\tKEY (`totalDownloads`),\n\t\t\t\tKEY (`iterationDownloads`),\n\t\t\t\tFOREIGN KEY (`bid`)\n\t\t\t\t\tREFERENCES build_builds(`id`)\n\t\t\t\t\tON UPDATE CASCADE\n\t\t\t\t\tON DELETE CASCADE)")) {
             throw new Exception("Failed to create build stats table: " . $database->error());
         }
         if (!$database->query("CREATE TABLE IF NOT EXISTS `tag_stats` (\n\t\t\t\t`tid` INT NOT NULL,\n\t\t\t\t`totalDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`iterationDownloads` INT NOT NULL DEFAULT 0,\n\t\t\t\tKEY (`totalDownloads`),\n\t\t\t\tKEY (`iterationDownloads`),\n\t\t\t\tFOREIGN KEY (`tid`)\n\t\t\t\t\tREFERENCES addon_tags(`id`)\n\t\t\t\t\tON UPDATE CASCADE\n\t\t\t\t\tON DELETE CASCADE)")) {
             throw new Exception("Failed to create tag stats table: " . $database->error());
         }
         //includes a lot of foreign keys, not sure if it is a good idea to include them all
         if (!$database->query("CREATE TABLE IF NOT EXISTS `statistics` (\n\t\t\t\t`id` INT NOT NULL AUTO_INCREMENT,\n\t\t\t\t`date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\t\t`users` INT NOT NULL DEFAULT 0,\n\t\t\t\t`addons` INT NOT NULL DEFAULT 0,\n\t\t\t\t`downloads` INT NOT NULL DEFAULT 0,\n\t\t\t\t`groups` INT NOT NULL DEFAULT 0,\n\t\t\t\t`comments` INT NOT NULL DEFAULT 0,\n\t\t\t\t`builds` INT NOT NULL DEFAULT 0,\n\t\t\t\t`tags` INT NOT NULL DEFAULT 0,\n\t\t\t\t`addon0` INT NOT NULL,\n\t\t\t\t`addon1` INT NOT NULL,\n\t\t\t\t`addon2` INT NOT NULL,\n\t\t\t\t`addon3` INT NOT NULL,\n\t\t\t\t`addon4` INT NOT NULL,\n\t\t\t\t`addon5` INT NOT NULL,\n\t\t\t\t`addon6` INT NOT NULL,\n\t\t\t\t`addon7` INT NOT NULL,\n\t\t\t\t`addon8` INT NOT NULL,\n\t\t\t\t`addon9` INT NOT NULL,\n\t\t\t\t`addonDownloads0` INT NOT NULL,\n\t\t\t\t`addonDownloads1` INT NOT NULL,\n\t\t\t\t`addonDownloads2` INT NOT NULL,\n\t\t\t\t`addonDownloads3` INT NOT NULL,\n\t\t\t\t`addonDownloads4` INT NOT NULL,\n\t\t\t\t`addonDownloads5` INT NOT NULL,\n\t\t\t\t`addonDownloads6` INT NOT NULL,\n\t\t\t\t`addonDownloads7` INT NOT NULL,\n\t\t\t\t`addonDownloads8` INT NOT NULL,\n\t\t\t\t`addonDownloads9` INT NOT NULL,\n\t\t\t\t`tag0` INT NOT NULL,\n\t\t\t\t`tag1` INT NOT NULL,\n\t\t\t\t`tag2` INT NOT NULL,\n\t\t\t\t`tag3` INT NOT NULL,\n\t\t\t\t`tag4` INT NOT NULL,\n\t\t\t\t`tagDownloads0` INT NOT NULL,\n\t\t\t\t`tagDownloads1` INT NOT NULL,\n\t\t\t\t`tagDownloads2` INT NOT NULL,\n\t\t\t\t`tagDownloads3` INT NOT NULL,\n\t\t\t\t`tagDownloads4` INT NOT NULL,\n\t\t\t\t`build0` INT NOT NULL,\n\t\t\t\t`build1` INT NOT NULL,\n\t\t\t\t`build2` INT NOT NULL,\n\t\t\t\t`buildDownloads0` INT NOT NULL,\n\t\t\t\t`buildDownloads1` INT NOT NULL,\n\t\t\t\t`buildDownloads2` INT NOT NULL,\n\t\t\t\tKEY (`date`),\n\t\t\t\tPRIMARY KEY (`id`))")) {
             throw new Exception("Failed to create stat history table: " . $database->error());
         }
     }
 }
Example #20
0
 /**
  * Processes and outputs one simple value.
  *
  * 1. Check for expression and comparison attributes
  * 2. Execute process_value() if no expression / comparison
  * 3. Execute wrap() and outputs the value
  *
  * @param	FTL_Binding
  * @param	mixed
  *
  * @return string
  *
  */
 public static function output_value(FTL_Binding $tag, $value)
 {
     $is = $tag->getAttribute('is');
     $in = $tag->getAttribute('in');
     $is_not = $tag->getAttribute('is_not');
     $expression = $tag->getAttribute('expression');
     $autolink = $tag->getAttribute('autolink');
     // "is" and "expression" cannot be used together.
     if (!is_null($is)) {
         // Do not pass the attribute to child
         $tag->removeAttribute('is');
         if (strtolower($is) == 'true') {
             $is = TRUE;
         }
         if (strtolower($is) == 'false') {
             $is = FALSE;
         }
         if ($value == $is) {
             if (self::$trigger_else > 0) {
                 self::$trigger_else = 0;
             }
             return self::wrap($tag, $tag->expand());
         } else {
             self::$trigger_else++;
             return '';
         }
     } else {
         if (!is_null($in)) {
             // Do not pass the attribute to child
             $tag->removeAttribute('in');
             $in = explode(',', $in);
             foreach ($in as $i) {
                 $i = trim($i);
                 if (strtolower($i) == 'true') {
                     $is = TRUE;
                 }
                 if (strtolower($i) == 'false') {
                     $is = FALSE;
                 }
                 if ($value == $i) {
                     if (self::$trigger_else > 0) {
                         self::$trigger_else = 0;
                     }
                     return self::wrap($tag, $tag->expand());
                 }
             }
             self::$trigger_else++;
             return '';
         } else {
             if (!is_null($is_not)) {
                 $tag->removeAttribute('is_not');
                 if (strtolower($is_not) == 'true') {
                     $is_not = TRUE;
                 }
                 if (strtolower($is_not) == 'false') {
                     $is_not = FALSE;
                 }
                 if ($value != $is_not) {
                     if (self::$trigger_else > 0) {
                         self::$trigger_else = 0;
                     }
                     return self::wrap($tag, $tag->expand());
                 } else {
                     self::$trigger_else++;
                     return '';
                 }
             } else {
                 if (!is_null($expression)) {
                     // Do not pass the attribute to child
                     $tag->removeAttribute('expression');
                     $result = self::eval_expression($tag, $expression);
                     if ($result === TRUE) {
                         if (self::$trigger_else > 0) {
                             self::$trigger_else = 0;
                         }
                         return self::wrap($tag, $tag->expand());
                     } else {
                         if ($result === FALSE) {
                             self::$trigger_else++;
                             return '';
                         } else {
                             return self::show_tag_error($tag, 'Condition incorrect: ' . $expression);
                         }
                     }
                 } else {
                     if (!is_null($value)) {
                         // Process PHP, helper, prefix/suffix
                         $value = self::process_value($tag, $value);
                         // Autolink
                         if ($autolink) {
                             $value = auto_link($value, 'both', TRUE);
                         }
                         // Make sub tags like "nesting" or "trace" working
                         $tag->expand();
                         return self::wrap($tag, $value);
                     }
                 }
             }
         }
     }
     return $tag->expand();
 }
Example #21
0
<?php

require_once dirname(__DIR__) . "/../../../private/class/TagManager.php";
$ret = new stdClass();
$ret->tags = array();
$tags = TagManager::getAllTags();
foreach ($tags as $tag) {
    $rettag = new stdClass();
    $rettag->id = $tag->getId();
    $rettag->name = $tag->getName();
    $rettag->icon = $tag->getIcon();
    $rettag->color = $tag->getColor();
    $ret->tags[] = $rettag;
}
echo json_encode($ret, JSON_PRETTY_PRINT);
Example #22
0
 public static function getInstance()
 {
     if (self::$Instance === null) {
         $thisClass = __CLASS__;
         self::$Instance = new $thisClass();
     }
     return self::$Instance;
 }
    <link rel="icon" href="../favicon.png" type="image/x-icon"/>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
	<link href="/style/style.css" rel="stylesheet" type="text/css" />
	<title>Tag Cloud: UIUC Campustown Dining Assistant</title>
</head>
<body>
<h1 id="header">UIUC Campustown Dining Assistant - Tag Cloud</h1>

<?php 
require '../cgi-bin/navbar.php';
?>

<div id="divTagC"><?php 
// Create the tag cloud.
include "../cgi-bin/TagManager.class.php";
$tManager = new TagManager();
$tags = $tManager->GetTagCloud();
$maxCount = NULL;
$minCount = NULL;
foreach ($tags as $tag) {
    $maxCount = $tag->count > $maxCount ? $tag->count : $maxCount;
    $minCount = $tag->count < $minCount || $minCount == NULL ? $tag->count : $minCount;
}
$maxCountThird = $maxCount / 3;
foreach ($tags as $tag) {
    if ($tag->count == $maxCount) {
        $class = 'largeTag';
    } else {
        if ($tag->count >= $maxCountThird) {
            $class = 'mediumTag';
        } else {
Example #24
0
 function update($post, $editor)
 {
     parent::update($post, $editor, self::OBJECT_CLASS);
     if (!AuthorizationManager::canUserDo(DB::EDIT_POST, $object)) {
         throw new Exception("L'utente non è autorizzato ad effettuare questa operazione.");
     }
     $p_old = $this->quickLoad($post->getID());
     $data = array();
     if (is_null($p_old)) {
         throw new Exception("L'oggetto da modificare non esiste.");
     }
     //cerco le differenze e le salvo.
     if ($p_old->getTitle() != $post->getTitle()) {
         $data[DB::POST_TITLE] = $post->getTitle();
     }
     if ($p_old->getSubtitle() != $post->getSubtitle()) {
         $data[DB::POST_SUBTITLE] = $post->getSubtitle();
     }
     if ($p_old->getHeadline() != $post->getHeadline()) {
         $data[DB::POST_HEADLINE] = $post->getHeadline();
     }
     if ($p_old->getContent() != $post->getContent()) {
         if ($post->type == Post::NEWS || $post->type == Post::VIDEOREP) {
             $data[DB::POST_CONTENT] = $post->getContent();
         } else {
             $data[DB::POST_CONTENT] = serialize($post->getContent());
         }
     }
     if ($p_old->getPlace() != $post->getPlace()) {
         $data[DB::POST_PLACE] = $post->getPlace();
     }
     if ($p_old->getPlaceName() != $post->getPlaceName()) {
         $data[DB::POST_PLACE_NAME] = $post->getPlaceName();
     }
     if ($p_old->getTags() != $post->getTags()) {
         $data[DB::POST_TAGS] = $post->getTags();
     }
     if ($p_old->getCategories() != $post->getCategories()) {
         // check sulle categorie, eliminazione di quelle che non esistono nel sistema, se vuoto inserimento di quella di default
         require_once 'manager/CategoryManager.php';
         $new_cat = CategoryManager::filterWrongCategories(explode(",", $post->getCategories()));
         if (count($new_cat) == 0) {
             $new_cat[] = self::DEFAULT_CATEGORY;
         }
         $post->setCategories(Filter::arrayToText($new_cat));
         $data[DB::POST_CATEGORIES] = $post->getCategories();
     }
     if ($p_old->isVisible() !== $post->isVisible()) {
         $data[DB::POST_VISIBLE] = $post->isVisible() ? 1 : 0;
     }
     if ($p_old->getPermalink() != $post->getPermalink()) {
         if ($this->permalinkExists($post->getPermalink())) {
             throw new Exception("Il permalink inserito esiste già. Riprova.");
         }
         $data[DB::POST_PERMALINK] = $post->getPermalink();
     }
     if (count($data) == 0) {
         throw new Exception("Nessuna modifica da effettuare.");
     }
     $modDate = $_SERVER["REQUEST_TIME"];
     $data[DB::POST_MODIFICATION_DATE] = date("Y/m/d G:i:s", $modDate);
     // se mi dicono di fare l'update, cambio modificationDate
     //salvo la versione precedente e ne tengo traccia.
     $history_id = $this->saveHistory($p_old, "UPDATED");
     $post->setPreviousVersion($history_id);
     $data[DB::POST_PREVIOUS_VERSION] = $post->getPreviousVersion();
     $rs = $this->db->execute($s = Query::generateUpdateStm($this->table, $data, array(new WhereConstraint($this->table->getColumn(DB::POST_ID), Operator::EQUAL, $post->getID()))), $this->table->getName(), $post);
     //aggiorno lo stato del post (se chi l'ha modificato è un redattore).
     if (AuthenticationManager::isEditor($editor)) {
         $post->setEditable(false);
         $post->setRemovable(false);
         $this->updateState($post);
     }
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore aggiornando il dato. Riprovare.");
     }
     //salvo i tag che non esistono
     if (isset($data[DB::POST_TAGS]) && !is_null($data[DB::POST_TAGS]) && trim($data[DB::POST_TAGS]) != "") {
         require_once 'manager/TagManager.php';
         TagManager::createTags(explode(",", $data[DB::POST_TAGS]));
         //TODO
     }
     return $post->setModificationDate($modDate);
 }
 /**
  * Update a system tag for this user
  * @param array(
  * 		oldTag => array(
  *			label => String,
  *			color => String,
  *		),
  *		newTag => array(
  *			label => String,
  *			color => String
  *		)
  * )
  */
 public function updateTag($params)
 {
     if ($params === null) {
         throw new EyeInvalidArgumentException('Missing $params');
     }
     if (!isset($params['oldTag']) || !is_array($params['oldTag'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $params[\'oldTag\']');
     }
     if (!isset($params['newTag']) || !is_array($params['newTag'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $params[\'newTag\']');
     }
     $oldTag = $params['oldTag'];
     $newTag = $params['newTag'];
     if (!isset($oldTag['label']) || !is_string($oldTag['label'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $oldTag[\'label\']');
     }
     if (!isset($newTag['label']) || !is_string($newTag['label'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $newTag[\'label\']');
     }
     if (!isset($oldTag['color']) || !is_string($oldTag['color'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $oldTag[\'color\']');
     }
     if (!isset($newTag['color']) || !is_string($newTag['color'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $newTag[\'color\']');
     }
     $oldTag = new BasicTag($oldTag['label'], $oldTag['color']);
     $newTag = new BasicTag($newTag['label'], $newTag['color']);
     $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
     TagManager::getInstance()->updateTag($currentUser, $oldTag, $newTag);
 }
Example #26
0
 /**
  * Return sites by tag
  *
  * @param string $tag
  * @param boolean $asArray
  * @return Site[]
  */
 public function getSitesByTag($tag, $asArray = false)
 {
     $result = [];
     $tagID = TagManager::getID($tag);
     if ($tagID) {
         $tagID = array_keys($tagID);
     }
     if ($sites = $this->dbh->getColumn('share_sites_tags', 'site_id', ['tag_id' => $tagID])) {
         $result = array_map(function ($siteID) use($asArray) {
             return !$asArray ? $this->getSiteByID($siteID) : $siteID;
         }, $sites);
     }
     return $result;
 }
Example #27
0
<?php

//collects together all the information needed by /addons/addon.php
if (!isset($_GET['id'])) {
    return false;
}
require_once realpath(dirname(__DIR__) . "/class/AddonManager.php");
require_once realpath(dirname(__DIR__) . "/class/UserManager.php");
require_once realpath(dirname(__DIR__) . "/class/TagManager.php");
require_once realpath(dirname(__DIR__) . "/class/DependencyManager.php");
$addon = AddonManager::getFromID($_GET['id'] + 0);
if ($addon === false) {
    return false;
}
$user = UserManager::getFromBLID($addon->blid);
$tagIDs = $addon->getTags();
$dependencyIDs = $addon->getDependencies();
$tags = [];
$dependencies = [];
foreach ($tagIDS as $tid) {
    $tags[] = TagManager::getFromID($tid);
}
foreach ($dependencyIDs as $did) {
    $dependencies[] = DependencyManager::getFromID($did);
}
//to do: replace "downloads" with "stats"
$response = ["addon" => $addon, "user" => $user, "tags" => $tags, "dependencies" => $dependencies, "downloads" => $addon->getTotalDownloads()];
return $response;
Example #28
0
 /**
  * Renders one view containing ionize tags
  *
  * Must be called from one module controller
  *
  * @param null  $view
  * @param array $data		Array of vars to pass to the view
  *                     		To get them from one view, use :
  *                     		<ion:get key="foo" />
  * @param bool  $return
  */
 public function render($view = NULL, $data = array(), $return = FALSE)
 {
     require_once APPPATH . 'libraries/Tagmanager.php';
     foreach ($data as $key => $value) {
         if (!is_string($value)) {
             $value = json_encode($value);
         }
         TagManager::$context->set_global($key, $value);
     }
     TagManager::render($view, $return);
 }
Example #29
0
 public function executeTagList()
 {
     $this->allTagsPager = TagManager::getTags($this->entity, $this->page);
 }
Example #30
0
 function update($resource, $editor)
 {
     parent::update($resource, $editor, self::OBJECT_CLASS);
     $r_old = $this->quickLoad($resource->getID());
     if (is_null($r_old)) {
         throw new Exception("L'oggetto da modificare non esiste.");
     }
     $data = array();
     //cerco le differenze POSSIBILI e le salvo.
     if ($r_old->getDescription() != $resource->getDescription()) {
         $data[DB::RESOURCE_DESCRIPTION] = $resource->getDescription();
     }
     if ($r_old->getTags() != $resource->getTags()) {
         $data[DB::RESOURCE_TAGS] = $resource->getTags();
     }
     $modDate = $_SERVER["REQUEST_TIME"];
     $data[DB::RESOURCE_MODIFICATION_DATE] = date("Y/m/d G:i:s", $modDate);
     //salvo la versione precedente e ne tengo traccia.
     $history_id = $this->saveHistory($r_old, $editor, "UPDATED");
     $resource->setPreviousVersion($history_id);
     $data[DB::PREVIOUS_VERSION] = $resource->getPreviousVersion();
     $rs = $this->db->execute($s = Query::generateUpdateStm($this->table, $data, array(new WhereConstraint($this->table->getColumn(DB::RESOURCE_ID), Operator::EQUAL, $resource->getID()))), $this->table->getName(), $resource);
     //TODO decommentare quando AuthenticationManager è operativo
     //aggiorno lo stato della risorsa (se chi l'ha modificata è un redattore).
     //if(AuthenticationManager::isEditor($editor)) {
     //	$resource->setEditable(false);
     //	$resource->setRemovable(false);
     //	$this->updateState($resource);
     //}
     if ($this->db->affected_rows() != 1) {
         throw new Exception("Si è verificato un errore aggiornando il dato. Riprovare.");
     }
     //salvo i tag che non esistono
     if (!is_null($resource->getTags()) && trim($resource->getTags()) != "") {
         TagManager::createTags(explode(",", $resource->getTags()));
     }
     return $resource->setModificationDate($modDate);
 }